Closed konekwok closed 4 months ago
启动代码如下: package com.main.game; import com.iohao.game.bolt.broker.core.client.BrokerAddress; import com.iohao.game.bolt.broker.core.common.IoGameGlobalConfig; import com.iohao.game.bolt.broker.server.BrokerServer; import com.iohao.game.external.core.ExternalServer; import com.iohao.game.external.core.config.ExternalGlobalConfig; import com.iohao.game.external.core.config.ExternalJoinEnum; import com.iohao.game.external.core.netty.DefaultExternalServer; import com.iohao.game.external.core.netty.DefaultExternalServerBuilder; import com.iohao.game.external.core.netty.simple.NettyRunOne; import com.match3.game.logic.MainLogic; import lombok.extern.slf4j.Slf4j; public class Main { public static void main(String[] args) {
log.info("Hello world!");
// 游戏对外服端口
// 逻辑服
var mainlogic = new MainLogic();
int externalPort = 10100;
// 启动游戏对外服、Broker(游戏网关)、游戏逻辑服
// 这三部分在一个进程中相互使用内存通信
log.info("start server!");
// 游戏对外服
ExternalServer externalServerWebSocket = createExternalServer(externalPort, ExternalJoinEnum.WEBSOCKET);
new NettyRunOne()
// broker (游戏网关)
.setBrokerServer(BrokerServer.newBuilder().build())
// 游戏对外服
// .setExternalServerList(List.of(externalServerWebSocket, externalServerTcp)) .setExternalServer(externalServerWebSocket) // 游戏逻辑服列表 .setLogicServerList(List.of(mainlogic)) // 启动 游戏对外服、游戏网关、游戏逻辑服 .startup();
// 生成对接文档
// BarSkeletonDoc.me().buildDoc(); } public static ExternalServer createExternalServer(int externalPort, ExternalJoinEnum joinEnum) {
// true 表示开启 traceId 特性;https://www.yuque.com/iohao/game/zurusq
IoGameGlobalConfig.openTraceId = false;
// 路由访问权限控制;https://www.yuque.com/iohao/game/nap5y8p5fevhv99y
extractedIgnore();
// 游戏对外服 - 构建器;https://www.yuque.com/iohao/game/ea6geg
DefaultExternalServerBuilder builder = DefaultExternalServer.newBuilder(externalPort)
// 连接方式;如果不设置,默认是 webSocket
.externalJoinEnum(joinEnum)
// Broker (游戏网关)的连接地址;如果不设置,默认也是这个配置
.brokerAddress(new BrokerAddress("127.0.0.1", IoGameGlobalConfig.brokerPort));
// 构建游戏对外服
return builder.build();
}
private static void extractedIgnore() {
/*
* 注意,权限相关验证配置在游戏对外服是正确的,因为是游戏对外服在控制访问验证
* see https://www.yuque.com/iohao/game/tywkqv#qEvtB
*/
var accessAuthenticationHook = ExternalGlobalConfig.accessAuthenticationHook;
// 表示登录才能访问业务方法
accessAuthenticationHook.setVerifyIdentity(true);
/*
* 由于 accessAuthenticationHook.verifyIdentity = true; 时,需要玩家登录才可以访问业务方法 (action)
*
* 在这可以配置一些忽略访问限制的路由。
* 这里配置的路由,表示不登录也可以进行访问
* 现在忽略的 3-1,是登录 action 的路由,所以当我们访问 3-1 路由时,可以不登录。
* 忽略的路由可以添加多个。
*/
// see HallCmdModule.cmd,HallCmdModule.loginVerify
accessAuthenticationHook.addIgnoreAuthCmd(1, 1);
accessAuthenticationHook.addIgnoreAuthCmd(3, 1);
accessAuthenticationHook.addIgnoreAuthCmd(3, 8);
accessAuthenticationHook.addIgnoreAuthCmd(3);
accessAuthenticationHook.addIgnoreAuthCmd(6);
}
}
可以提供一个可复现可运行的 demo 吗。
关闭 debug 日志
可以从文档中提供的相关示例源码仓库中,参考日志相关的配置。
可以从文档中提供的相关示例源码仓库中,参考日志相关的配置。
多谢
你的问题 | 使用场景
描述你遇到的问题,或使用场景(询问框架能否满足此类需求) 按安装教程,启动服务器后,一直报如下信息: DEBUG io.netty.channel.DefaultChannelPipeline -- Discarded inbound message com.alipay.remoting.rpc.HeartbeatCommand@7814fac5 that reached at the tail of the pipeline. Please check your pipeline configuration.
预期值
期望的预期值
实际值
实际值