• Stars
    star
    1,243
  • Rank 36,239 (Top 0.8 %)
  • Language
    Go
  • License
    MIT License
  • Created about 11 years ago
  • Updated almost 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Game Server Skeleton in golang.

A game server skeleton implemented with golang.

Architecture

注意(NOTICE)

欢迎加入QQ群: 459420581 (Gopher成都,讨论一切与go有关的话题)

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 可随意重启,不影响业务

安装先决条件:

  1. 确保安装好graphviz, gawk
  2. 确保安装好mongodb
  3. 确保config.ini中的mongo_xxxx配置正确
  4. 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

####支持此项目 ( Donations ) :
donate
欢迎使用支付宝扫描上面的二维码,对该项目进行捐赠。捐赠款项将用于持续优化补全及完善。

More Repositories

1

kcptun

A Stable & Secure Tunnel based on KCP with N:M multiplexing and FEC. Available for ARM, MIPS, 386 and AMD64。N:M 多重化と FEC を備えた KCP に基づく安定した安全なトンネル。 N:M 다중화 및 FEC를 사용하는 KCP 기반의 안정적이고 안전한 터널입니다. Un tunnel stable et sécurisé basé sur KCP avec multiplexage N:M et FEC.
Go
13,605
star
2

algorithms

Algorithms & Data structures in C++.
C++
5,115
star
3

kcp-go

A Crypto-Secure, Production-Grade Reliable-UDP Library for golang with FEC
Go
3,879
star
4

smux

A Stream Multiplexing Library for golang with least memory usage(TDMA)
Go
1,214
star
5

gaio

High performance async-io(proactor) networking for Golang。golangのための高性能非同期io(proactor)ネットワーキング
Go
545
star
6

libkcp

FEC enhanced KCP session library for iOS/Android in C++
C
293
star
7

tcpraw

Sending packets through TCP
Go
125
star
8

safebox

One key to derive all
Go
55
star
9

buddha

佛教资料汇集
54
star
10

navmesh

navigation mesh in golang
Go
41
star
11

sp

Stream Processors on Kafka in Golang
Go
29
star
12

chat

pub/sub based chat server
Go
27
star
13

rank

ranking server
Go
23
star
14

sstable

bigdata processing in golang
Go
23
star
15

lossyconn

lossy connection simulator
Go
20
star
16

rewind

Text-Based UI for Kafka
Go
20
star
17

goeval

eval golang code on the fly
Go
15
star
18

log_analysis

Practical Log Analysis
15
star
19

fibernet

Message Queue/C++/Lua based game server
C
15
star
20

wsl-best-practice

best practice for development environment in WSL
14
star
21

notes

personal notes
Go
12
star
22

gogw

Go
9
star
23

auth

auth service
Go
8
star
24

goperf

golang performance benchmarks
Go
7
star
25

bgsave

background save process of redis
Go
7
star
26

serialpacket

net.PacketConn over RS232/LoRa
Go
6
star
27

reorg

A simulated LFN network to mitigate network jitter, reorg trade latency in exchange for smoothness, so as to behave like a long fat but stable network.
Go
5
star
28

tmach

turing machine game
Go
5
star
29

xtaci

4
star
30

json2hive

generate hive schema from a json document
Go
4
star
31

chacha20

an exposed version of https://godoc.org/golang.org/x/crypto/internal/chacha20
Go
4
star
32

kidsmath

a simple program to generate math quizs for my kid.
Go
3
star
33

archiver

redolog archive and replay
Go
3
star
34

serial2tun

Serial To Tun Device
3
star
35

easenet

Automatically exported from code.google.com/p/easenet
C
3
star
36

zturn

(zturn:折腾) a free game brings you back to 1980s
3
star
37

goscm

simple scheme interpreter
Go
1
star
38

poly2tri.as3

Automatically exported from code.google.com/p/poly2tri.as3
ActionScript
1
star
39

logrushooks

hooks for logrus
Go
1
star
40

poly2tri

Automatically exported from code.google.com/p/poly2tri
C++
1
star
41

godeep

machine learning algorithms
1
star
42

ssh-kvr

lex/yacc learning
C
1
star
43

deadlocks

deadlock code snippets in C
C
1
star
44

algebra

notes on algebra learning
1
star
45

log4go

Automatically exported from code.google.com/p/log4go
Go
1
star
46

debris

Shamir's Secret Sharing
1
star
47

ethereum_indexer

A project for indexing and querying ethereum accounts
Go
1
star