Skip to content

Commit

Permalink
🐳 #376 i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
iohao committed Oct 3, 2024
1 parent 54e28ca commit 965f859
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,18 @@
public interface MessageKey {
String cmdName = "cmdName";
String gameExternalServer = "gameExternalServer";
String gameServerAmount = "gameServerAmount";
/** ExternalJoinEnum */
String connectionWay = "connectionWay";

/* about brokerServer */
String gameBrokerServer = "gameBrokerServer";
String gameBrokerServerStartupMode = "gameBrokerServerStartupMode";
String gameBrokerServerStartupModeCluster = "gameBrokerServerStartupModeCluster";
String gameBrokerServerStartupModeStandalone = "gameBrokerServerStartupModeStandalone";
String gameBrokerServerConnectionAmount = "gameBrokerServerConnectionAmount";
String brokerClientRegistrationMessage = "brokerClientRegistrationMessage";

/* see PrintActionKit.java */
String printActionKitPrintClose = "printActionKitPrintClose";
String printActionKitPrintFull = "printActionKitPrintFull";
Expand Down
14 changes: 14 additions & 0 deletions common/common-core/src/main/resources/iohao.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
# common
gameExternalServer=GameExternalServer
cmdName=Routing
# see BrokerClientNodeInfo.java
gameServerAmount=Number of servers
# ExternalJoinEnum
connectionWay=Connection way
# about brokerServer
gameBrokerServer=GameBrokerServer
gameBrokerServerStartupMode=Startup Mode
gameBrokerServerStartupModeStandalone=Standalone
gameBrokerServerStartupModeCluster=Cluster
gameBrokerServerConnectionAmount=Number of GameBrokerServer connections

brokerClientRegistrationMessage=Module registration information

# about ConnectionEvent


# see PrintActionKit.java
printActionKitPrintClose=To turn off printing, see
printActionKitPrintFull=Print the full package name, see
Expand Down
33 changes: 20 additions & 13 deletions common/common-core/src/main/resources/iohao_zh_CN.properties
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
# common
gameExternalServer=\u6E38\u620F\u5BF9\u5916\u670D
cmdName=\u8DEF\u7531
gameServerAmount=??????
gameExternalServer=?????
cmdName=??
# ExternalJoinEnum
connectionWay=\u8FDE\u63A5\u65B9\u5F0F
connectionWay=????
gameBrokerServer=BrokerServer
gameBrokerServerStartupMode=????
gameBrokerServerStartupModeStandalone=??
gameBrokerServerStartupModeCluster=????
gameBrokerServerConnectionAmount=GameBrokerServer ????
brokerClientRegistrationMessage=??????
# see PrintActionKit.java
printActionKitPrintClose=\u5173\u95ED\u6253\u5370, \u67E5\u770B
printActionKitPrintFull=\u6253\u5370\u5B8C\u6574\u5305\u540D, \u67E5\u770B
printActionKitDataCodec=\u5F53\u524D\u4F7F\u7528\u7684\u7F16\u89E3\u7801\u5668
printActionKitCheckReturnType=action \u8FD4\u56DE\u503C\u548C\u53C2\u6570\u4E0D\u652F\u6301 set\u3001map \u548C \u57FA\u7840\u7C7B\u578B!
printActionKitPrintClose=????, ??
printActionKitPrintFull=??????, ??
printActionKitDataCodec=?????????
printActionKitCheckReturnType=action ????????? set?map ? ????!
# see DebugInOut.java
debugInOutThreadName=\u7EBF\u7A0B
debugInOutParamName=\u53C2\u6570
debugInOutReturnData=\u54CD\u5E94
debugInOutErrorCode=\u9519\u8BEF\u7801
debugInOutErrorMsg=\u9519\u8BEF\u4FE1\u606F
debugInOutTime=\u8017\u65F6
debugInOutThreadName=??
debugInOutParamName=??
debugInOutReturnData=??
debugInOutErrorCode=???
debugInOutErrorMsg=????
debugInOutTime=??
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.iohao.game.action.skeleton.core.BarSkeleton;
import com.iohao.game.action.skeleton.core.BarSkeletonBuilder;
import com.iohao.game.action.skeleton.i18n.Bundle;
import com.iohao.game.action.skeleton.i18n.MessageKey;
import com.iohao.game.bolt.broker.client.AbstractBrokerClientStartup;
import com.iohao.game.bolt.broker.client.processor.BrokerClusterMessageClientProcessor;
import com.iohao.game.bolt.broker.client.processor.RequestBrokerClientModuleMessageClientProcessor;
Expand Down Expand Up @@ -58,9 +60,11 @@ public BarSkeleton createBarSkeleton() {

@Override
public BrokerClientBuilder createBrokerClientBuilder() {
String gameExternalServer = Bundle.getMessage(MessageKey.gameExternalServer);

return BrokerClient.newBuilder()
.id(this.id)
.appName("新游戏对外服")
.appName(gameExternalServer)
// 逻辑服标签 (tag 相当于归类)
.tag("external")
// 逻辑服设置为对外服类型
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* ioGame
* ioGame
* Copyright (C) 2021 - present 渔民小镇 (262610965@qq.com、luoyizhu@gmail.com) . All Rights Reserved.
* # iohao.com . 渔民小镇
*
Expand All @@ -18,6 +18,9 @@
*/
package com.iohao.game.bolt.broker.cluster;

import com.iohao.game.action.skeleton.i18n.Bundle;
import com.iohao.game.action.skeleton.i18n.MessageKey;

/**
* broker (游戏网关)的启动模式
*
Expand All @@ -26,9 +29,9 @@
*/
public enum BrokerRunModeEnum {
/** 单机启动模式 */
STANDALONE("单机启动模式 standalone"),
STANDALONE(Bundle.getMessage(MessageKey.gameBrokerServerStartupModeStandalone)),
/** 集群启动模式 */
CLUSTER("集群启动模式 cluster");
CLUSTER(Bundle.getMessage(MessageKey.gameBrokerServerStartupModeCluster));

final String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import com.alipay.remoting.rpc.RpcConfigs;
import com.alipay.remoting.rpc.RpcServer;
import com.iohao.game.action.skeleton.i18n.Bundle;
import com.iohao.game.action.skeleton.i18n.MessageKey;
import com.iohao.game.action.skeleton.toy.IoGameBanner;
import com.iohao.game.bolt.broker.cluster.BrokerClusterManager;
import com.iohao.game.bolt.broker.cluster.BrokerRunModeEnum;
Expand Down Expand Up @@ -99,12 +101,21 @@ public void startup() {
// 启动集群
Optional.ofNullable(this.brokerClusterManager).ifPresent(BrokerClusterManager::start);

log.info("启动游戏网关 port: [{}] 启动模式: [{}] ", this.port, this.brokerRunMode);
extractedLog();

IoGameBanner.render();
IoGameBanner.me().countDown();
}

private void extractedLog() {
String gameBrokerServer = Bundle.getMessage(MessageKey.gameBrokerServerConnectionAmount);
String gameBrokerServerStartupMode = Bundle.getMessage(MessageKey.gameBrokerServerStartupMode);
log.info("{} port:[{}] - {}:[{}] ",
gameBrokerServer, this.port,
gameBrokerServerStartupMode, this.brokerRunMode
);
}

public void shutdown() {
this.rpcServer.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package com.iohao.game.bolt.broker.server.kit;

import com.iohao.game.action.skeleton.i18n.Bundle;
import com.iohao.game.action.skeleton.i18n.MessageKey;
import com.iohao.game.bolt.broker.core.common.IoGameGlobalConfig;
import com.iohao.game.bolt.broker.server.BrokerServer;
import com.iohao.game.bolt.broker.server.balanced.BalancedManager;
Expand Down Expand Up @@ -57,7 +59,9 @@ public void print(BrokerServer brokerServer) {

// 对外服信息
int externalCount = balancedManager.getExternalLoadBalanced().count();
BrokerClientNodeInfo externalNodeInfo = new BrokerClientNodeInfo("游戏对外服", externalCount);
var gameExternalServer = Bundle.getMessage(MessageKey.gameExternalServer);

BrokerClientNodeInfo externalNodeInfo = new BrokerClientNodeInfo("external", externalCount);
collect.add(externalNodeInfo);

String info = collect.stream()
Expand All @@ -66,16 +70,19 @@ public void print(BrokerServer brokerServer) {

int port = brokerServer.getPort();

log.info("当前网关【{}】与逻辑服相关信息: {}", port, info);
var gameBrokerServer = Bundle.getMessage(MessageKey.gameBrokerServer);
log.info("{}:{} --- gameLogicServerList: {}", gameBrokerServer, port, info);
}

private record BrokerClientNodeInfo(String tag, int count) {
@Override
public String toString() {
var gameServerAmount = Bundle.getMessage(MessageKey.gameServerAmount);

return "{" +
"服务器数量:" + count +
", tag:'" + tag + '\'' +
'}';
gameServerAmount + ":" + count +
", tag:'" + tag + '\'' +
'}';
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.alipay.remoting.BizContext;
import com.alipay.remoting.exception.RemotingException;
import com.alipay.remoting.rpc.protocol.AsyncUserProcessor;
import com.iohao.game.action.skeleton.i18n.Bundle;
import com.iohao.game.action.skeleton.i18n.MessageKey;
import com.iohao.game.bolt.broker.cluster.BrokerClusterManager;
import com.iohao.game.bolt.broker.cluster.BrokerRunModeEnum;
import com.iohao.game.bolt.broker.core.aware.CmdRegionsAware;
Expand Down Expand Up @@ -119,9 +121,15 @@ private void sendClusterMessage(BizContext bizCtx) {

private void print(BrokerClientModuleMessage brokerClientModuleMessage) {

int port = this.brokerServer.getPort();
if (IoGameGlobalConfig.openLog) {
log.info("模块注册信息 --- 网关port: [{}] --- {}", port, brokerClientModuleMessage);
var port = this.brokerServer.getPort();
var brokerClientRegistrationMessage = Bundle.getMessage(MessageKey.brokerClientRegistrationMessage);
var gameBrokerServer = Bundle.getMessage(MessageKey.gameBrokerServer);

log.info("{} --- {} port: [{}] --- {}",
brokerClientRegistrationMessage,
gameBrokerServer, port,
brokerClientModuleMessage);
}

// print
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.alipay.remoting.Connection;
import com.alipay.remoting.ConnectionEventProcessor;
import com.alipay.remoting.ConnectionEventType;
import com.iohao.game.action.skeleton.i18n.Bundle;
import com.iohao.game.action.skeleton.i18n.MessageKey;
import com.iohao.game.bolt.broker.core.aware.BrokerClientItemAware;
import com.iohao.game.bolt.broker.core.client.BrokerClient;
import com.iohao.game.bolt.broker.core.client.BrokerClientItem;
Expand Down Expand Up @@ -79,9 +81,12 @@ private void extracted(String remoteAddress, Connection conn) {
brokerClientManager.register(brokerClientItem);

if (IoGameGlobalConfig.openLog) {
log.info("ConnectionEventType:【{}】 remoteAddress:【{}】,网关连接数量:【{}】,registerActive:【{}】",
String gameBrokerServerConnectionAmount = Bundle.getMessage(MessageKey.gameBrokerServerConnectionAmount);

log.info("ConnectionEventType:【{}】 remoteAddress:【{}】,{}:【{}】,registerActive:【{}】",
ConnectionEventType.CONNECT,
remoteAddress,
gameBrokerServerConnectionAmount,
brokerClientManager.countItem(),
brokerClientManager.countActiveItem()
);
Expand Down

0 comments on commit 965f859

Please sign in to comment.