From 6af22f72459ef05150bb9c1efa1f776ea6ff5f2f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B8=94=E6=B0=91=E5=B0=8F=E9=95=87?= <262610965@qq.com>
Date: Mon, 18 Nov 2024 21:26:38 +0800
Subject: [PATCH] :whale: #376 i18n DefaultUserHook
---
.../skeleton/core/doc/package-info.java | 29 ++++++++++++++++---
.../game/action/skeleton/i18n/MessageKey.java | 4 +++
.../src/main/resources/iohao.properties | 3 ++
.../src/main/resources/iohao_zh_CN.properties | 3 ++
.../core/hook/internal/DefaultUserHook.java | 11 +++++--
5 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/package-info.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/package-info.java
index 5072043a8..91d1835eb 100644
--- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/package-info.java
+++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/core/doc/package-info.java
@@ -17,20 +17,41 @@
* along with this program. If not, see
{@code * public static void main(String[] args) { * // 添加枚举错误码 class,用于生成错误码相关信息 * IoGameDocumentHelper.addErrorCodeClass(GameCode.class); * - * // 添加文档生成器,文本文档 - * IoGameDocumentHelper.addDocumentGenerate(new TextDocumentGenerate()); - * // 添加文档生成器,Ts 联调代码生成。(暂未开放) + * // 添加代码生成器,生成 C# 联调代码。(21.20 支持) + * // IoGameDocumentHelper.addDocumentGenerate(new CsharpDocumentGenerate()); + * // 添加代码生成器,生成 Ts 联调代码。(21.21 支持) * // IoGameDocumentHelper.addDocumentGenerate(new TypeScriptDocumentGenerate()); * // 生成文档 * IoGameDocumentHelper.generateDocument(); * } * }+ * 介绍 + *
+ * ioGame 是非常注重开发体验的,代码注释即文档、方法即交互接口的原则。 + * + * ioGame 具备一次编写到处对接的能力,从而做到了你们团队提升巨大的生产力可能性。 + * 一次编写指的是编写一次 java 业务代码,而到处对接则是指为不同的前端项目生成与服务器交互的代码。 + * + * ioGame 能为各种前端项目生成 action、广播、错误码 相关接口代码。 + * 这将意味着,你只需要编写一次业务代码,就可以同时与这些游戏引擎或现代化的前端框架交互。 + *+ * 代码生成的几个优势 + *
+ * 1. 帮助客户端开发者减少巨大的工作量,不需要编写大量的模板代码。 + * 2. 语义明确,清晰。生成的交互代码即能明确所需要的参数类型,又能明确服务器是否会有返回值。这些会在生成接口时就提前明确好。 + * 3. 由于我们可以做到明确交互接口,进而可以明确参数类型。这使得接口方法参数类型安全、明确,从而有效避免安全隐患,从而减少联调时的低级错误。 + * 4. 减少服务器与客户端双方对接时的沟通成本,代码即文档。生成的联调代码中有文档与使用示例,方法上的示例会教你如何使用,即使是新手也能做到零学习成本。 + * 5. 帮助客户端开发者屏蔽与服务器交互部分,将更多的精力放在真正的业务上。 + * 6. 为双方联调减少心智负担。联调代码使用简单,与本地方法调用一般丝滑。 + * 7. 抛弃传统面向协议对接的方式,转而使用面向接口方法的对接方式。 + * 8. 当我们的 java 代码编写完成后,我们的文档及交互接口可做到同步更新,不需要额外花时间去维护对接文档及其内容。 + ** * @author 渔民小镇 * @date 2024-08-05 diff --git a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java index 4825b19e7..a551a85c6 100644 --- a/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java +++ b/common/common-core/src/main/java/com/iohao/game/action/skeleton/i18n/MessageKey.java @@ -77,4 +77,8 @@ public interface MessageKey { String textDocumentCmd = "textDocumentCmd"; String textDocumentBroadcast = "textDocumentBroadcast"; String textDocumentErrorCodeTitle = "textDocumentErrorCodeTitle"; + + /* see DefaultUserHook.java */ + String userHookInto = "userHookInto"; + String userHookQuit = "userHookQuit"; } diff --git a/common/common-core/src/main/resources/iohao.properties b/common/common-core/src/main/resources/iohao.properties index 587a4ec8e..0f36ad222 100644 --- a/common/common-core/src/main/resources/iohao.properties +++ b/common/common-core/src/main/resources/iohao.properties @@ -45,3 +45,6 @@ textDocumentBroadcastTitle=Other broadcast interfaces textDocumentCmd=Routing textDocumentBroadcast=Broadcast textDocumentErrorCodeTitle=Error Code +# see DefaultUserHook +userHookInto=[PlayerOnline] CountOnline +userHookQuit=[PlayerOffline] CountOnline \ No newline at end of file diff --git a/common/common-core/src/main/resources/iohao_zh_CN.properties b/common/common-core/src/main/resources/iohao_zh_CN.properties index 7293e8090..f0a3cf4f3 100644 --- a/common/common-core/src/main/resources/iohao_zh_CN.properties +++ b/common/common-core/src/main/resources/iohao_zh_CN.properties @@ -45,3 +45,6 @@ textDocumentBroadcastTitle=其它广播推送 textDocumentCmd=路由 textDocumentBroadcast=广播 textDocumentErrorCodeTitle=错误码 +# see DefaultUserHook +userHookInto=[玩家上线] 在线数量 +userHookQuit=[玩家下线] 在线数量 diff --git a/external/external-core/src/main/java/com/iohao/game/external/core/hook/internal/DefaultUserHook.java b/external/external-core/src/main/java/com/iohao/game/external/core/hook/internal/DefaultUserHook.java index 54fcbba3a..843698afa 100644 --- a/external/external-core/src/main/java/com/iohao/game/external/core/hook/internal/DefaultUserHook.java +++ b/external/external-core/src/main/java/com/iohao/game/external/core/hook/internal/DefaultUserHook.java @@ -18,6 +18,8 @@ */ package com.iohao.game.external.core.hook.internal; +import com.iohao.game.action.skeleton.i18n.Bundle; +import com.iohao.game.action.skeleton.i18n.MessageKey; import com.iohao.game.common.consts.IoGameLogName; import com.iohao.game.external.core.aware.UserSessionsAware; import com.iohao.game.external.core.hook.UserHook; @@ -43,16 +45,19 @@ public void setUserSessions(UserSessions, ?> userSessions) { @Override public void into(UserSession userSession) { long userId = userSession.getUserId(); - log.info("[玩家上线] 在线数量:{} userId:{} -- {}" + log.info("{}:{} userId:{} -- {}, into" + , Bundle.getMessage(MessageKey.userHookInto) , userSessions.countOnline() , userId, userSession.getUserChannelId()); } @Override public void quit(UserSession userSession) { + long userId = userSession.getUserId(); - log.info("[玩家下线] 在线数量:{} userId:{} -- {}", - userSessions.countOnline() + log.info("{}:{} userId:{} -- {}, quit" + , Bundle.getMessage(MessageKey.userHookQuit) + , userSessions.countOnline() , userId, userSession.getUserChannelId()); } }