Goserver
基于nats的分布式的游戏服务器框架
Install / Use
/learn @0990/GoserverREADME
goserver
基于消息队列(nats)的游戏服务器框架
架构
<br>
分布式服务器以nats为消息交换中心,客户端发送的消息统一由gate服进行路由转发
1,gate服
和客户端通信使用websocket,仅支持protobuf,数据结构:<br>
-------------------------
| id | protobuf message |
-------------------------
id是消息名的Hash值,用于标记消息名,反解析数据<br> 因为websocket协议已经支持iframe分帧处理,不需要处理粘包,故包结构中无需包长度字段<br>
2,多服rpc通信
使用nats(消息队列)构建服务器间通信,支持send,request,call请求
更多技术细节: https://www.jianshu.com/p/74904ace2349
配置
gate服: server.NewGate(serverId,listenAddr,goserver.Config{Nats: natsAddr}) <br> 其它服: server.NewServer(serverId,goserver.Config{Nats: natsAddr})<br>
其中,每个服务器有个唯一serverId即可,natsAddr就是nats的地址,gate服多一个listenAddr代表监听端口<br>
示例
1,启动消息队列服务(https://github.com/nats-io/nats-streaming-server) <br> 2,见example目录,依次启动user/main.go,gate/main.go,client/main.go<br> 先启动user服,再启动gate服,gate向user服发送rpc消息,通知型:pb.ReqSend{},请求回应型:pb.ReqRequest{}<br> 最后启动client,会模拟发送客户端消息pb.ReqHello,此消息会被gate转发到user服,模拟路由消息情况
基于goserver的游戏服务器
avatar-fight-server https://github.com/0990/avatar-fight-server
Related Skills
canvas
337.3kCanvas Skill Display HTML content on connected OpenClaw nodes (Mac app, iOS, Android). Overview The canvas tool lets you present web content on any connected node's canvas view. Great for: -
node-connect
337.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
337.3kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
83.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
