Skip to content

通用的实时流golang框架,可以方便的创建游戏服务/聊天服务等

License

Notifications You must be signed in to change notification settings

gfandada/gserver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 16, 2019
ee7ecfe · Apr 16, 2019
Mar 26, 2019
Mar 9, 2018
Jul 27, 2017
Dec 8, 2017
Apr 2, 2019
Apr 2, 2019
Nov 7, 2018
Oct 30, 2017
Jul 11, 2017
Sep 15, 2017
Nov 1, 2017
Oct 20, 2017
Sep 22, 2017
Dec 8, 2017
Mar 8, 2019
Mar 26, 2019
Mar 26, 2019
Sep 15, 2017
Mar 26, 2019
Oct 22, 2017
Dec 6, 2017
Jan 26, 2018
Feb 13, 2018

Repository files navigation

gserver

This project aims to provide a solution for real-time message flow.
You can create GameServer or others, with gserver.
The communication protocol of GateWay has supported Tcp and Websocket.
DEMO is here. (tcp-gateway and mobagame-service)
LICENSE is here.

Installation

golang version 1.9.2
go get github.com/golang/protobuf/proto
go get github.com/gorilla/websocket
go get github.com/cihub/seelog
go get github.com/koding/multiconfig
go get github.com/garyburd/redigo/redis
go get github.com/HuKeping/rbtree
go get github.com/tealeg/xlsx
go get google.golang.org/grpc
go get github.com/go-sql-driver/mysql

TODO

current version is v0.8.3
next version-v0.9.0 will focus on:
1.optimize safe -- ING
2.optimize microservice
3.add inner logger -- ING
4.add tcp gateway -- DONE
5.add game util package(aoi,space,entity....) -- ING

CONF

更全的配置请查看demo工程
{
	"MaxConnNum": 2048, // 最大连接数:多余的连接将不会响应
	"PendingNum": 100,  // gateway->client异步ipc队列上限
	"MaxMsgLen": 1024,  // client<->gateway message上限:单位byte
	"MinMsgLen": 0,     // client<->gateway message下限:单位byte
	"ReadDeadline":60,  // gateway->client读超时:单位s
	"WriteDeadline":60, // gateway->client写超时:单位s
	"ServerAddress": "localhost:9527", // gateway地址
	"MaxHeader":1024,   // header上限(for websocket):单位byte
	"HttpTimeout": 10,  // http-get超时(for websocket):单位s
	"CertFile": "",     // for ssl
	"KeyFile": "",      // for ssl
	"Rpm":100,          // client->gateway流量上限:每分钟收到的报文数量上限
	"AsyncMQ":64,       // service->gateway异步ipc队列上限
	"GateWayIds":1999   // gateway本地路由id段(当前路由规则是简单的id分段规则)
}

Message

client->gateway
	----------------------------
	| len | seq | id | message |
	----------------------------
	len:seq + id + message,占用2个字节(uint16)
	seq:从1自增的序列号,占用4个字节(uint32)
	id:协议号,占用2个字节(uint16)
	message:业务数据,占用len-6字节,可以使用任意编码:pb/json等,本框架内置了pb2编码器

gateway->client
	----------------------
	| len | id | message |
	----------------------
	len:id + message的长度,占用2个字节(uint16)
	id:协议号,占用两个字节(uint16)
	message:业务数据,占用len-2字节,可以使用任意编码:pb/json等,本框架内置了pb2编码器
	
gateway<->service(base pb3)
	type Data_Frame struct {
		Type    Data_FrameType
		Message []byte
	}

dataflow

image

About

通用的实时流golang框架,可以方便的创建游戏服务/聊天服务等

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages