|
@@ -24,8 +24,11 @@ import com.iohao.game.external.core.ExternalServer;
|
|
|
import com.iohao.game.external.core.broker.client.ext.ExternalBizRegions;
|
|
|
import com.iohao.game.external.core.config.ExternalGlobalConfig;
|
|
|
import com.iohao.game.external.core.config.ExternalJoinEnum;
|
|
|
+import com.iohao.game.external.core.micro.PipelineContext;
|
|
|
import com.iohao.game.external.core.netty.DefaultExternalServer;
|
|
|
import com.iohao.game.external.core.netty.DefaultExternalServerBuilder;
|
|
|
+import com.iohao.game.external.core.netty.handler.ws.HttpRealIpHandler;
|
|
|
+import com.iohao.game.external.core.netty.micro.WebSocketMicroBootstrapFlow;
|
|
|
import com.iohao.mmo.external.core.broker.client.ext.impl.UserIpExternalBizRegion;
|
|
|
import com.iohao.mmo.login.cmd.LoginCmd;
|
|
|
|
|
@@ -47,6 +50,18 @@ public class MyExternalServer {
|
|
|
// Broker (游戏网关)的连接地址;如果不设置,默认也是这个配置
|
|
|
.brokerAddress(new BrokerAddress("127.0.0.1", IoGameGlobalConfig.brokerPort));
|
|
|
|
|
|
+ builder.setting().setMicroBootstrapFlow(new WebSocketMicroBootstrapFlow() {
|
|
|
+ @Override
|
|
|
+ protected void httpHandler(PipelineContext context) {
|
|
|
+ super.httpHandler(context);
|
|
|
+ /*
|
|
|
+ * HttpRealIpHandler 是框架内置的一个 handler。
|
|
|
+ * 添加上后,即使是通过 nginx 转发,也可以得到玩家真实的 ip
|
|
|
+ */
|
|
|
+ context.addLast("HttpRealIpHandler", new HttpRealIpHandler());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
// 构建游戏对外服 https://www.yuque.com/iohao/game/ea6geg
|
|
|
return builder.build();
|
|
|
}
|