{"id":48947268,"url":"https://github.com/0990/goserver","last_synced_at":"2026-04-17T17:32:44.006Z","repository":{"id":42879465,"uuid":"194360586","full_name":"0990/goserver","owner":"0990","description":"基于nats的分布式的游戏服务器框架","archived":false,"fork":false,"pushed_at":"2023-10-25T04:51:26.000Z","size":118,"stargazers_count":67,"open_issues_count":0,"forks_count":24,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-15T02:43:53.426Z","etag":null,"topics":["gameserver","golang","nats","rpc","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","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/0990.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":"2019-06-29T03:36:43.000Z","updated_at":"2025-07-28T11:46:08.000Z","dependencies_parsed_at":"2024-06-18T22:38:27.981Z","dependency_job_id":"dab0b305-1bae-4fa3-81af-71096f19f013","html_url":"https://github.com/0990/goserver","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/0990/goserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0990%2Fgoserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0990%2Fgoserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0990%2Fgoserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0990%2Fgoserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0990","download_url":"https://codeload.github.com/0990/goserver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0990%2Fgoserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31938759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["gameserver","golang","nats","rpc","websocket"],"created_at":"2026-04-17T17:32:40.974Z","updated_at":"2026-04-17T17:32:43.999Z","avatar_url":"https://github.com/0990.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# goserver\n基于消息队列（nats)的游戏服务器框架\n\n# 架构\n![framework](doc/goserver_framework.png)\u003cbr\u003e\n分布式服务器以nats为消息交换中心，客户端发送的消息统一由gate服进行路由转发\n\n\n## 1,gate服\n和客户端通信使用websocket，仅支持protobuf，数据结构：\u003cbr\u003e\n\n    -------------------------\n    | id | protobuf message |\n    -------------------------\nid是消息名的Hash值，用于标记消息名，反解析数据\u003cbr\u003e\n因为websocket协议已经支持iframe分帧处理，不需要处理粘包，故包结构中无需包长度字段\u003cbr\u003e\n\n## 2，多服rpc通信\n使用nats(消息队列)构建服务器间通信，支持send,request,call请求\n\n更多技术细节: https://www.jianshu.com/p/74904ace2349\n\n## 配置\ngate服: server.NewGate(serverId,listenAddr,goserver.Config{Nats: natsAddr}) \u003cbr\u003e\n其它服: server.NewServer(serverId,goserver.Config{Nats: natsAddr})\u003cbr\u003e\n\n其中，每个服务器有个唯一serverId即可,natsAddr就是nats的地址,gate服多一个listenAddr代表监听端口\u003cbr\u003e\n# 示例\n1，启动消息队列服务（https://github.com/nats-io/nats-streaming-server) \u003cbr\u003e\n2，见example目录，依次启动user/main.go,gate/main.go,client/main.go\u003cbr\u003e\n先启动user服，再启动gate服，gate向user服发送rpc消息，通知型:pb.ReqSend{},请求回应型:pb.ReqRequest{}\u003cbr\u003e\n最后启动client,会模拟发送客户端消息pb.ReqHello,此消息会被gate转发到user服，模拟路由消息情况\n\n# 基于goserver的游戏服务器\navatar-fight-server https://github.com/0990/avatar-fight-server\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0990%2Fgoserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0990%2Fgoserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0990%2Fgoserver/lists"}