GithubHelp home page GithubHelp logo

tempbottle / cellnet Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davyxu/cellnet

0.0 2.0 1.0 2.04 MB

简单,方便,高效的Go语言的游戏服务器框架

License: MIT License

Go 96.58% Batchfile 0.45% Protocol Buffer 2.97%

cellnet's Introduction

Cellnet

简单,方便,高效的Go语言的游戏服务器框架

特性

异步单线程多进程架构

  • 无需处理繁琐的多线程安全问题
  • 底层IO仍然使用goroutine进行处理, 保证IO吞吐率
  • 性能敏感的业务拆离为单独进程进行处理

数据协议

  • 封包类型采用Type-Length-Value的私有tcp封包, 自带序列号防御简单的封包复制
  • 消息统一使用Protobuf格式进行通信

网关

  • 基本的网关透传框架
  • 广播,列表广播

RPC

  • 异步远程过程调用

异步MongoDB

  • 提供KV数据库的基本抽象

模块化

  • 鼓励使用统一的模块化命名及拆分方法进行隔离降偶

日志

  • 分级日志

第三方库依赖

  • github.com/golang/protobuf/proto
  • github.com/BurntSushi/toml
  • gopkg.in/mgo.v2

例子

Echo

func server() {

	pipe := cellnet.NewEventPipe()

	evq := socket.NewAcceptor(pipe).Start("127.0.0.1:7234")

	socket.RegisterSessionMessage(evq, coredef.TestEchoACK{}, func(content interface{}, ses cellnet.Session) {
		msg := content.(*coredef.TestEchoACK)

		log.Println("server recv:", msg.String())

		ses.Send(&coredef.TestEchoACK{
			Content: proto.String(msg.String()),
		})

	})

	pipe.Start()

}

func client() {

	pipe := cellnet.NewEventPipe()

	evq := socket.NewConnector(pipe).Start("127.0.0.1:7234")

	socket.RegisterSessionMessage(evq, coredef.TestEchoACK{}, func(content interface{}, ses cellnet.Session) {
		msg := content.(*coredef.TestEchoACK)

		log.Println("client recv:", msg.String())

	})

	socket.RegisterSessionMessage(evq, coredef.SessionConnected{}, func(content interface{}, ses cellnet.Session) {

		ses.Send(&coredef.TestEchoACK{
			Content: proto.String("hello"),
		})

	})

	pipe.Start()
}

新品预告!

消息日志

  • 可以方便的通过日志查看收发消息(Protobuf)的每一个字段消息

MongoDB

  • DB内存映射框架
  • DB存储日志

网关

  • 可定制的消息路由规则

备注

cellnet当前主要开发环境是Windows, 所以工具、Shell相关都会以Windows为主 后期会对Linux平台的开发环境进行支持

推荐使用LiteIDE进行开发及查看 https://github.com/visualfc/liteide

感觉不错请fork和star, 谢谢!

博客: http://www.cppblog.com/sunicdavy

知乎: http://www.zhihu.com/people/xu-bo-62-87

技术讨论组: 309800774 加群请说明cellnet

邮箱: [email protected]

cellnet's People

Contributors

davyxu avatar

Watchers

 avatar  avatar

Forkers

redbamleaves

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.