Skip to content

ioGame 21.22 Netty Java Game Server

Latest
Compare
Choose a tag to compare
@iohao iohao released this 02 Dec 04:09

Documentation and Logs

Releases: 1 to 2 versions are released every month, and upgrades within a major version are always compatible, such as 21.1 is upgraded to any higher version 21.x


Version update summary

  1. perf(core): DefaultActionMethodParamParser
  2. fix(kit): #407 ClassRefInfoKit invokeSetter
  3. #376 i18n DefaultUserHook
  4. feat(GenerateCode): #329 Added TypeScript code generation TypeScriptDocumentGenerate, which can generate interactive code for CocosCreator、Vue、Angular.

feat(GenerateCode): #329 Added TypeScript code generation TypeScriptDocumentGenerate, which can generate interactive code for CocosCreator、Vue、Angular.

About examples

  1. ioGameServerExample: https://github.com/iohao/ioGameExamples/tree/main/SdkExample
  2. CocosCreatorExample: https://github.com/iohao/ioGameSdkTsExampleCocos
  3. VueExample: https://github.com/iohao/ioGameSdkTsExampleVue
  4. HtmlExample: https://github.com/iohao/ioGameSdkTsExampleHtml
  5. AngularExample: https://github.com/iohao/ioGameSdkTsExampleAngular
public final class GenerateTest {
    // setting root path
    static String rootPath = "/Users/join/gitme/ioGame-sdk/";

    public static void main(String[] args) {
        // CHINA or US
        Locale.setDefault(Locale.CHINA);

        // Load the business framework of each gameLogicServer
        // 加载游戏逻辑服的业务框架
        yourListLogic().forEach(BrokerClientStartup::createBarSkeleton);

        /*
         * Generate actions, broadcasts, and error codes.
         * cn: 生成 action、广播、错误码
         */
        
         // About generating TypeScript code
//        generateCodeVue();
//        generateCodeAngular();
//        generateCodeHtml();
        generateCocosCreator();

        // Added an enumeration error code class to generate error code related information
        IoGameDocumentHelper.addErrorCodeClass(YourGameCodeEnum.class);
        // Generate document
        IoGameDocumentHelper.generateDocument();
    }

    private static void generateCodeVue() {
        var documentGenerate = new TypeScriptDocumentGenerate();

        // 设置代码生成所存放的路径,如果不做任何设置,将会生成在 target/code 目录中
        // By default, it will be generated in the target/code directory
        String path = rootPath + "ioGameSdkTsExampleVue/src/assets/gen/code";
        documentGenerate.setPath(path);

        // Your .proto path: Set the import path of common_pb in Vue.
        documentGenerate.setProtoImportPath("../common_pb");

        IoGameDocumentHelper.addDocumentGenerate(documentGenerate);
    }

    private static void generateCodeHtml() {
        var documentGenerate = new TypeScriptDocumentGenerate();

        // 设置代码生成所存放的路径,如果不做任何设置,将会生成在 target/code 目录中
        // By default, it will be generated in the target/code directory
        String path = rootPath + "ioGameSdkTsExampleHtml/src/assets/gen/code";
        documentGenerate.setPath(path);

        // Your .proto path: Set the import path of common_pb in Vue.
        documentGenerate.setProtoImportPath("../common_pb");

        IoGameDocumentHelper.addDocumentGenerate(documentGenerate);
    }

    private static void generateCocosCreator() {
        var documentGenerate = new TypeScriptDocumentGenerate();

        // 设置代码生成所存放的路径,如果不做任何设置,将会生成在 target/code 目录中
        // By default, it will be generated in the target/code directory
        String path = rootPath + "ioGameSdkTsExampleCocos/assets/scripts/gen/code";
        documentGenerate.setPath(path);

        // Your .proto path: Set the import path of common_pb in CocosCreator
        documentGenerate.setProtoImportPath("db://assets/scripts/gen/common_pb");

        IoGameDocumentHelper.addDocumentGenerate(documentGenerate);
    }

    private static void generateCodeAngular() {
        var documentGenerate = new TypeScriptDocumentGenerate();

        // 设置代码生成所存放的路径,如果不做任何设置,将会生成在 target/code 目录中
        // By default, it will be generated in the target/code directory
        String path = rootPath + "ioGameSdkTsExampleAngular/src/assets/gen/code";
        documentGenerate.setPath(path);

        // Your .proto path: Set the import path of common_pb in Vue.
        documentGenerate.setProtoImportPath("../common_pb");

        IoGameDocumentHelper.addDocumentGenerate(documentGenerate);
    }
}

Advantages of SDK Code Generation

  1. Helps client-side developers reduce significant workload by eliminating the need to write a large amount of template code.
  2. Clear and semantically precise. The generated interaction code clearly defines parameter types and return types.
  3. Ensures parameter type safety and clarity in interface methods, effectively avoiding security risks and reducing basic errors during integration.
  4. Reduces communication costs between the server and client during integration; the code serves as documentation. The generated integration code includes documentation and usage examples, and the examples on the methods will guide you on how to use them, making it zero-learning-cost even for beginners.
  5. Helps client-side developers abstract away the interaction with the server, allowing them to focus more on the core business logic.
  6. Reduces the cognitive load during integration. The code is simple to use, similar to local method calls.
  7. Abandons the traditional protocol-based approach in favor of an interface-method-based integration approach.