Skip to content

ioGame 21.20 netty 分布式网络游戏服务器框架,真轻量级网络编程框架

Latest
Compare
Choose a tag to compare
@iohao iohao released this 15 Nov 15:23

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. feat(GenerateDoc): Add DocumentMethod annotation : Action supports generating documentation method names through annotations.
  2. BroadcastDebug enhancements.
  3. feat(GenerateCode): #328 Added C# code generation CsharpDocumentGenerate, which can generate interactive code for Unity and Godot.

feat(GenerateDoc): Add DocumentMethod annotation : Action supports generating documentation method names through annotations.

By default, the method names in the generated action interaction code use the method names from the Java action. The action can add the DocumentMethod annotation to fix the method name, and when generating the integration code, ioGame will prioritize using the value of the DocumentMethod annotation.

@ActionController(SdkCmd.cmd)
public final class SdkAction {    
    @ActionMethod(SdkCmd.noReturn)
    @DocumentMethod("noReturnMethod")
    public void noReturn(String name) {
        ... ...
    }
}

feat(GenerateCode): #328 Added C# code generation CsharpDocumentGenerate, which can generate interactive code for Unity and Godot.

About examples

  1. see https://github.com/iohao/ioGameExamples/tree/main/SdkExample
  2. UnityExample: https://github.com/iohao/ioGameSdkCsharpExampleUnity
  3. GodotExample: https://github.com/iohao/ioGameSdkCsharpExampleGodot
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 C# code
        generateCodeCsharpGodot();
        generateCodeCsharpUnity();

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

    private static void generateCodeCsharpUnity() {
        var documentGenerate = new CsharpDocumentGenerate();
        // 设置代码生成所存放的路径,如果不做任何设置,将会生成在 target/code 目录中
        // By default, it will be generated in the target/code directory
        String path = rootPath + "ioGameSdkCsharpExampleUnity/Assets/Scripts/Gen/Code";
        documentGenerate.setPath(path);

        IoGameDocumentHelper.addDocumentGenerate(documentGenerate);
    }

    private static void generateCodeCsharpGodot() {
        var documentGenerate = new CsharpDocumentGenerate();
        // 设置代码生成所存放的路径,如果不做任何设置,将会生成在 target/code 目录中
        // By default, it will be generated in the target/code directory
        String path = rootPath + "ioGameSdkCsharpExampleGodot/script/gen/code";
        documentGenerate.setPath(path);

        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.

[other updates]

<protobuf-java.version>3.25.5</protobuf-java.version>