Giter Club home page Giter Club logo

cellnet's Introduction

Cellnet

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

特性

异步单线程多进程架构

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

数据协议

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

网关

  • 基本的网关透传框架
  • 广播,列表广播
  • 可定制的消息路由规则

RPC

  • 异步远程过程调用

模块化

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

日志

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

第三方库依赖

  • github.com/golang/protobuf/proto
  • github.com/davyxu/golog
  • 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.Debugln("server recv:", msg.String())

		ses.Send(&coredef.TestEchoACK{
			Content: 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.Debugln("client recv:", msg.String())

	})

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

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

	})

	pipe.Start()
}

TODO

网关

  • 处理多同名svc时的转发

MongoDB

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

Wiki

https://github.com/davyxu/cellnet/wiki 这里有文档和架构,设计解析

备注

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

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

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

邮箱: [email protected]

战魂小筑技术讨论群: 309800774 加群请说明cellnet

cellnet发问请直接@成都_黑色灵猫

贡献者

viwii

cellnet's People

Contributors

davyxu avatar

Watchers

 avatar  avatar

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.