{"id":24387962,"url":"https://github.com/jiayaoguang/gameserver","last_synced_at":"2025-04-11T04:53:02.778Z","repository":{"id":30538164,"uuid":"125298412","full_name":"jiayaoguang/gameserver","owner":"jiayaoguang","description":"Game Server Framework ,and not only game; 游戏服务器框架,又不止是游戏。支持网页http请求, 支持长连接发送 protobuf、json、自定义的数据类型,数据压缩加密、依赖注入、mysql对象关系映射及异步存储等功能。","archived":false,"fork":false,"pushed_at":"2025-02-10T17:40:21.000Z","size":1606,"stargazers_count":26,"open_issues_count":3,"forks_count":12,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T04:52:56.873Z","etag":null,"topics":["game","game-development","game-server","gameserver","http","http-server","java","netty","protobuf"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jiayaoguang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-15T01:58:02.000Z","updated_at":"2025-03-01T15:45:14.000Z","dependencies_parsed_at":"2024-09-08T10:47:52.384Z","dependency_job_id":"800d74d4-64bc-4dd6-904a-c8cee867f110","html_url":"https://github.com/jiayaoguang/gameserver","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayaoguang%2Fgameserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayaoguang%2Fgameserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayaoguang%2Fgameserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jiayaoguang%2Fgameserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jiayaoguang","download_url":"https://codeload.github.com/jiayaoguang/gameserver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345291,"owners_count":21088243,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["game","game-development","game-server","gameserver","http","http-server","java","netty","protobuf"],"created_at":"2025-01-19T13:21:35.820Z","updated_at":"2025-04-11T04:53:02.756Z","avatar_url":"https://github.com/jiayaoguang.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"##   \u003cfont color=#f1986d size=3\u003e游戏服务器\u003c/font\u003e\n![Java CI](https://github.com/jiayaoguang/gameserver/workflows/Java%20CI/badge.svg)\n[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)\n![Maven](https://img.shields.io/maven-central/v/io.github.jiayaoguang/gameserver-core.svg)\n------\nMaven\n\n    \u003cdependency\u003e\n        \u003cgroupId\u003eio.github.jiayaoguang\u003c/groupId\u003e\n        \u003cartifactId\u003egameserver-core\u003c/artifactId\u003e\n        \u003cversion\u003e0.1.2\u003c/version\u003e\n    \u003c/dependency\u003e\n\n### [english introduction](https://github.com/jiayaoguang/gameserver/blob/main/README_EN.md)\n\n## 简介\n* 这是一个通用游戏服务器框架\n* 服务器以consumer 为运行单位,consumer 可以本地运行和调用,也可远程调用\n* consumer可以在单独的线程运行，也可以多个consumer运行在一个线程\n* 不同的consumer通信支持远程方法调用并异步返回，也可以通过发布事件的方法通信\n\n## Features\n* 与客户端的tcp通信格式是 int(消息体字节数组长度+4) int(消息id) byte[](消息体字节数组)\n* 消息体格式支持json protobuf 自定义格式 protobuf、json、自定义 的数据类型，支持压缩、加密操作\n* 支持 http tcp udp websocket 网络协议\n* 轻量级远程调用、依赖注入\n* 不重启更新\n* mysql对象关系映射及异步存储\n* 定时事件\n* 消息转发代理,添加消息转发代理服务器无需修改代码，只需让客户端改为连接转发代理服务器即可\n* 消息传递支持 MQ,socket , websocket\n* 远程方法调用  [example](https://github.com/jiayaoguang/gameserver/blob/main/gameserver-test/src/main/java/org/jyg/gameserver/test/invoke/InvokeMethodHttpServerDemo01.java) , 同步非阻塞调用 [example](https://github.com/jiayaoguang/gameserver/blob/main/gameserver-test/src/main/java/org/jyg/gameserver/test/invoke/SyncInvokeMethodServerDemo01.java)\n\n\n\n[服务器示例项目](https://github.com/jiayaoguang/gameserver/tree/main/gameserver-example) |\n[客户端示例项目](https://github.com/jiayaoguang/gameclient)\n\n\n\n构建处理 protoBuf数据的服务器例子:\n\n    public class PingServer {\n        public static void main(String[] args) throws Exception {\n            GameServerBootstrap bootstarp = new GameServerBootstrap();\n            bootstarp.registerSocketEvent(101, new PingProcessor());\n            bootstarp.registerSendEventIdByProto(102, p_test.p_scene_sm_response_pong.class);\n            //开端口服务\n            bootstarp.addTcpConnector(8080);\n            bootstarp.start();\n        }\n    \n        public static class PingProcessor extends ProtoProcessor\u003cp_sm_scene_request_ping\u003e {\n    \n            @Override\n            public void process(Session session, p_sm_scene_request_ping msg) {\n                System.out.println(\"ok , i see ping\");\n                session.writeMessage(p_test.p_scene_sm_response_pong.newBuilder());\n            }\n        }\n    }\n\nhttp例子代码:\n\n    public class HttpServerDemo01\n    {\n        public static void main ( String[] args ) throws Exception \n        {\n        \t\n        \t\n        \tGameServerBootstrap bootstarp = new GameServerBootstrap();\n            \n            bootstarp.addHttpProcessor(new HttpProcessor(\"/index\") {\n    \t\t\t\n    \t\t\t@Override\n    \t\t\tpublic void service(Request request, Response response) {\n    \n    \t\t\t\tresponse.writeAndFlush( \"\u003chtml\u003e\u003chead\u003e\u003c/head\u003e\u003cbody\u003e\u003cdiv align='center'\u003e\u003ch1\u003eHello world!\u003c/h1\u003e\u003c/div\u003e\u003cbody\u003e\u003c/html\u003e\" );\n    \t\t\t\t\n    \t\t\t}\n    \t\t} );\n            \n            bootstarp.addHttpConnector(8080);\n            \n            bootstarp.start();\n        }\n    }\n\n远程调用:\n    \n\n    //服务器处理逻辑\n    public static class PlusManager {\n        @RemoteMethod(uname = \"plus\")\n        public int plus(int a, int b) {\n            Logs.CONSUMER.info(\"plus : {}\", (a + b));\n\n            return a + b;\n        }\n    }\n\n\n    //客户端代理接口\n    public static interface PlusManagerProxy {\n\n        @InvokeRemoteMethod(uname = \"plus\", targetConsumerId = 10086)\n        public InvokeRemoteResultFuture\u003cInteger\u003e plus(int a, int b);\n\n    }\n\n    //客户端创建调用代理\n    PlusManagerProxy plusManagerProxy = gameConsumer.getRemoteMethodInvokeManager().getOrCreateRemoteMethodProxy(PlusManagerProxy.class);\n\n    //客户端发起远程调用\n    InvokeRemoteResultFuture\u003cInteger\u003e resultFuture = plusManagerProxy.plus(100, 200);\n\n\n    //客户端设置获取结果后的处理逻辑\n    resultFuture.setResultHandler(new ResultHandler\u003cInteger\u003e() {\n        @Override\n        public void call(int eventId, Integer result) {\n            Logs.DEFAULT_LOGGER.info(\"get plus result : \" + result);\n        }\n    });\n\n[远程调用完整代码](https://github.com/jiayaoguang/gameserver/blob/main/gameserver-test/src/main/java/org/jyg/gameserver/test/invoke/ProxyInvokeMethodFutureServerDemo01.java)\n\n更多例子请在 [test](https://github.com/jiayaoguang/gameserver/tree/main/gameserver-test/src/main/java/org/jyg/gameserver/test) 包查看\n\n----------\n## License\n[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html) Copyright (C) Apache Software Foundation\n\t\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiayaoguang%2Fgameserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiayaoguang%2Fgameserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiayaoguang%2Fgameserver/lists"}