Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xtaci/gonet
A Game Server Skeleton in golang.
https://github.com/xtaci/gonet
Last synced: 21 days ago
JSON representation
A Game Server Skeleton in golang.
- Host: GitHub
- URL: https://github.com/xtaci/gonet
- Owner: xtaci
- License: mit
- Created: 2013-04-11T02:18:23.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2024-07-25T03:40:39.000Z (3 months ago)
- Last Synced: 2024-10-01T15:21:35.219Z (about 1 month ago)
- Language: Go
- Homepage:
- Size: 1.42 MB
- Stars: 1,261
- Watchers: 136
- Forks: 296
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - gonet - Game server skeleton implemented with golang. (Game Development / Search and Analytic Databases)
- awesome-go - gonet - Game server skeleton implemented with golang. Stars:`1.3K`. (Game Development / Search and Analytic Databases)
- awesome-go - gonet - A Game Server Skeleton in golang. - ★ 962 (Game Development)
- awesome-go-extra - gonet - 04-11T02:18:23Z|2017-05-12T07:31:41Z| (Game Development / Advanced Console UIs)
README
### A game server skeleton implemented with golang.
![Architecture](doc/arch.png)### gonet/2
gonet1已停止维护(I no longer maintain this, please move forward to http://github.com/gonet2 )
建议移步至新架构: http://gonet2.github.io
#### 部署:
* Game Server(GS):
玩家直接连接GS, 处理玩家逻辑,并与 HUB/SS 通信,GS存在若干个。
(Players connect directly to GS(s) and process, GS(s) will communication with HUB)
* Hub Server(HUB):
若干个GS 连接到一个HUB, 只存在一个HUB,维护基础的全局信息,以及 GS<--->GS 的消息转发.
(packet forwarding)
* Stats Server(SS):
统计服务器,根据玩家的行为,记录策划需要的数据,以便于后期统计。
统计属于事后分析,数据量较大,性能需求不同, 故单独列为一个服务器。#### 通信原则:
1. GS到HUB/SS的通信,都是Call同步调用,即GS必须等待ACK。
2. HUB到GS的通信,只有forward数据包。
3. 单播消息在玩家离线时会存入db, 登录后的启动过程 ___GS___ 直接读取db,并forward给玩家goroutine。(持久化)
4. 多播消息会发送给所有的在线玩家(非持久化)
5. 广播消息会发送给所有的在线玩家(非持久化)#### 服务器状态一致性
1. GS节点可以单独重启
2. HUB 重启后,GS必须全部重启
3. SS 可随意重启,不影响业务#### 安装先决条件:
0. 确保安装好graphviz, gawk
1. 确保安装好mongodb
2. 确保config.ini中的mongo_xxxx配置正确
3. export GOPATH='当前目录'#### 安装:
* xtaci@ubuntu:~$ git clone https://github.com/xtaci/gonet
* xtaci@ubuntu:~$ cd gonet
* xtaci@ubuntu:~/gonet$ export GOPATH=~/gonet
* xtaci@ubuntu:~/gonet$ go get gopkg.in/mgo.v2
* xtaci@ubuntu:~/gonet$ make
* xtaci@ubuntu:~/gonet$ ./start-test.sh