golang有没有好的开源游戏服务端框架框架

您所在的位置: &
历数2013年优秀的开源游戏引擎与开源游戏项目
历数2013年优秀的开源游戏引擎与开源游戏项目
2013年是移动游戏爆发的一年,也是开源游戏爆发的一年!在这里,我们历数一下2013年都有哪些优秀的开源游戏诞生,还有哪些优秀的开源游戏技术解决方案诞生!
2013年是移动游戏爆发的一年,也是开源游戏爆发的一年!在这里,我们历数一下2013年都有哪些优秀的开源游戏诞生,还有哪些优秀的开源游戏技术解决方案诞生!
开源跨平台2D客户端引擎 Cocos2d-x
MIT 协议,Cocos2D-X是全球知名的开源跨平台手机游戏引擎,易学易用,目前已经支持iOS、Android、Windows8、Mac
OSX、Linux、BlackBerry、Windows
Phone等平台。Cocos2D-HTML5基于HTML5规范集开发,实现了引擎对浏览器的支持。现在cocos2d-x团队隶属于触控,据说触控要 上市了。
cocos2d-x项目地址:
开源游戏服务器端框架 Firefly
MIT协议,Firefly是免费、开源、稳定、快速扩展、能 &热更新&的分布式游戏服务器端框架,采用Python编写,业内小有名气,目前有几十家游戏开发团队在使用Firefly开发手机网游产品,十几款已上线产品,优势是国内最大的开源游戏社区&自研,所以游戏开发者的讨论交流活跃度的确是国内最高的,也是目前版本迭代频率最快的。
Firefly项目地址:
开源游戏服务器端框架 pomelo
MIT协议,pomelo 是由开发的基于开发的高性能、分布式游戏服务器框架, 也可作为高实时web应用框架。目前pomelo是基于node.js上做的优秀游戏服务器端框架,文档非常详细。
pomelo项目地址:
开源游戏地图编辑器MarbleMap
MIT协议,MarbleMap是一款as3开发的游戏地图编辑器,他免费开源,同时支持Cocos2d-x坐标系和AS3坐标系,功能丰富,不过是一款新推出的开源项目,较为年轻。
MarbleMap项目地址:
开源卡牌手机网游《DiabloWorld》(中文名:暗黑世界)
MIT协议,频繁迭代的卡牌类手机网游开源项目,是国内第一款开源的卡牌手游项目。服务器端基于Firefly客户端基于cocos2d-x,20多个系统玩法,已经迭代了6个版本,并先后被上海专家组和北京专家组的不同地区开发者推出了U3D版本分支和AIR版本分支。
《暗黑世界》项目地址:
开源45度RPG网页游戏《烽烟OL》
MIT协议,一款由Firefly+as3开发的网页游戏,30多个系统玩法,目前已经跟新到1.6版本,是一个很优秀的商品级开源项目,维护团队还是很友好的,所有问题几乎都会进行回答。
《烽烟OL》项目地址:
开源对战手机网游《进击的9秒》
MIT协议,一款强调布阵然后对战的手机网游,算是SRPG类型,团队战斗力强悍,不过文档少,目前已经有2款基于这款游戏修改出来的产品上线运营了!
《进击的9秒》项目地址:
【编辑推荐】
【责任编辑: TEL:(010)】
关于&&的更多文章
Android Studio是一套面世不久的IDE(即集成开发环境),免费向
讲师: 98人学习过讲师: 122人学习过讲师: 32人学习过
随着云计算、物联网、大数据、移动互联网的大发展,你应该知道这些。
2013年手机游戏大火,但随着很多人涌入进来,同质化和
写给开发人员――苹果的最新一代移动操作系统已经正式
大家有木有感觉很奇怪呢,现在都12月份了,北京还没下
《程序员密码学》涉及密码学的各个研究方向,分组密码、散列函数、公钥密码以及相关的攻击,同时也讲解了密码学算法实现上常用的
Windows Phone专家
Android开发专家
51CTO旗下网站golang开源即时通信框架
golang开源及时通信框架:Lhttp是一个基于websocket服务端框架,提供一个类似http的协议去帮助开发者开发长连接的应用。
使用Lhttp可以大量减少服务端开发的工作量,实现非常好的模块化和业务功能的解耦合。
可以定制任何你想要的功能。
使用简单,功能强大 性能高,使用gnatsd消息队列 publish 10000 条消息耗时0.04s(single-core CPU,1G memory). 支持集群,横向扩展,通过增加服务器来获取更高的服务能力 非常容器进行定制与扩展 可以非常好的与http服务协同工作,如利用http发送消息,将消息转发给上游http服务器等。所以即便你不会go语言也可以开发一些应用。
+--------------------+
+--------------------+
+--------------------+
+--------------------+
+---------------------------------------+
message center cluster (gnatsd)
+---------------------------------------+
........|.................|...............|..................
| +-------------+
+-------------+
+-------------+
| |lhttp server |
|lhttp server |
|lhttp server |
lhttp 服务集群
| +-------------+
+-------------+
+-------------+
.....|..........._____|
|___.............|
|_________......
&----使用websocket链接
+--------+
+--------+
+--------+
+--------+
+--------+
| client |
| client |
| client |
| client |
| client |
+--------+
+--------+
+--------+
+--------+
+--------+
go /nats-io/nats
go /fanux/lhttp
先启动gnatsd:
./gnatsd &
打开另一个终端,执行客户端程序,输入命令码:
./lhttpClient
使用docker快速体验
$ docker build -t lhttp:latest .
$ docker run -p
lhttp:latest
打开,访问: http://localhost:9090.
打开两个窗口就可以聊起来了。
websocket 端口是 8081, 可以使用自己的websocket客户端去连 ws://localhost:8081
也可以从dockerhub上下载镜像:
$ docker run -p
fanux/lhttp:latest
LHTTP/1.0 Command\r\n
--------起始行,协议名和版本,Command:非常重要,标识这条消息的命令码是什么,服务端也是根据命令码注册对应的处理器的。
Header1:value\r\n
--------首部
Header2:value\r\n
--------消息体
LHTTP/1.0 chat\r\n
命令码叫`chat`
content-type:json\r\n
消息体使用json编码
publish:channel_jack\r\n
服务端请把这条消息publish给jack (jack订阅了channel_jack)
from:mike,
message:hello jack,
time::30:48
使用教程,只需三步
定义你的处理器,需要聚合 BaseProcessor
type ChatProcessor struct {
*lhttp.BaseProcessor
实现三个接口,连接打开时干嘛,关闭时干嘛,消息到来时干嘛。
type ChatProcessor struct {
func (p ChatProcessor)OnOpen(h *WsHandler) {
//your logic
func (p ChatProcessor)OnClose(h *WsHandler) {
//your logic
func (p ChatProcessor)OnMessage(h *WsHandler) {
//your logic
注册你的处理器,这里的chat 与消息体中的chat对应,也就是这个处理器仅会处理LHTTP/1.0 chat\r\n....这类消息.
lhttp.Regist(&chat&,&ChatProcessor{&lhttp.BaseProcessor{}})
如果命令码是 &chat& ChatProcessor 会处理它。
这里比如收到消息就直接将消息返回:
func (p *ChatProcessor)OnMessage(h *WsHandler) {
h.Send(h.GetBody())
启动服务器
http.Handler(&/echo&,lhttp.Handler(lhttp.StartServer))
http.ListenAndServe(&:8081&)
一个完整的回射例子:
type ChatProcessor struct {
*lhttp.BaseProcessor
func (p *ChatProcessor) OnMessage (h *lhttp.WsHandler) {
log.Print(&on message :&, h.GetBody())
h.Send(h.GetBody())
func main(){
lhttp.Regist(&chat&, &ChatProcessor{&lhttp.BaseProcessor{}})
http.Handle(&/echo&,lhttp.Handler(lhttp.StartServer))
http.ListenAndServe(&:8081&,nil)
下面来看用Lhttp开发及时通信应用有多简单
假设有两个客户端,这里的客户端比如浏览器应用。
LHTTP/1.0 command\r\n
subscribe:channelID\r\n
body optional
client1通过websocket向Lhttp发送如上字符串,就订阅了channelId
LHTTP/1.0 command\r\n
publish:channelID\r\n
body require
client2通过websocket向Lhttp发送如上字符串,就向channelID发布了一条消息。 因为client1订阅了channelID,所以client1会收到这条消息。
client1不想再收消息,那么发如下字符串给服务端即可:
LHTTP/1.0 command\r\n
unsubscribe:channelID\r\n
body optional
订阅/发布 是lhttp内置功能,服务端一行代码不用写即可获取这种服务,只需要使用特定首部subscribe,publish 和unsubscribe
同时订阅多个,如同时订阅多个聊天室。
LHTTP/1.0 chat\r\n
subscribe:channelID1 channelID2 channelID3\r\n
使用http发布消息
URL: /publish .
方法: POST .
http body: 整个lhttp消息
for example I want send a message to who subscribe channel_test by HTTP.
如我想发送一条消息给订阅了channel_test的人。
resp,err := http.POST(&/publish&, &text/plain&,
&LHTTP/1.0 chat\r\npublish:channel_test\r\n\r\nhello channel_test guys!&)
这里封装好了一个更好用的工具 Publish tools.go
//func Publish(channelID []string, command string, header map[string]string, body string) (err error) {
//send message to who subscribe mike.
Publish(&mike&, &yourCommand&, nil, &hello mike!&)
上游服务器
upstream首部可以让lhttp向上游的http服务器发送一条消息。
LHTTP/1.0 command\r\n
upstream:POST \r\n
如果是POST方法,lhttp会把整个消息体当作http的body发送给
如果是GET,lhttp会忽略消息体
LHTTP/1.0 command\r\n
upstream:GET ?user=user_a&age=26\r\n
upstream有什么用:
如我们不想改动lhttp的代码,但是想存储聊天记录。
通过upstream可以实现很好的解耦:
并且http server可以用其它语言实现.
|_____________
+------------+
|lhttp server|
+------------+
|(http request with chat record)
+------------+
| http server|
upstream server(/record)
+------------+
(save chat record)
LHTTP/1.0 chat\r\n
upstream:POST /record\r\n
publish:channel_mike\r\n
hello mike,I am jack
LHTTP/1.0 chat\r\n
subscribe:channel_mike\r\n
这样jack publish消息时不仅mike可以收到,后端的upstream server也可以收到,我们可以在后端服务器中处理消息存储的逻辑,如将消息
存储到redis的有序集合中。
试想一下,一条消息中既有图片也有文字还有语音怎么办? lhttp的multipart首部解决这个问题
LHTTP/1.0 upload\r\n
multipart:0 56\r\n
content-type:text/json\r\n
{filename:file.txt,fileLen:5}
content-type:text/plain\r\n
content-type:text/json\r\n\r\n{filename:file.txt,fileLen:5}content-type:text/plain\r\n\r\nhello
|&---------------------first part-------------------------&|&---------second part------------&|
http中是使用boundry实现的,lhttp使用偏移量标识分块,这样效率更高,不需要遍历整个消息体。
如何获取分块消息
如客户端消息如下:
LHTTP/1.0 upload\r\nmultipart:0 14\r\n\r\nk1:v1\r\n\r\nbody1k2:v2\r\n\r\nbody2
服务端代码,消息存在链表中:
type UploadProcessor struct {
*lhttp.BaseProcessor
func (*UploadProcessor) OnMessage(ws *lhttp.WsHandler) {
for m := ws.GetMultipart(); m != m = m.GetNext() {
log.Print(&multibody:&, m.GetBody(), & headers:&, m.GetHeaders())
//don't forget to tegist your command processor
lhttp.Regist(&upload&, &UploadProcessor{&lhttp.BaseProcessor{}})一个Go(Golang)语言轻量级MVC框架:utron
来源:open开发经验库
utron是一个Go(Golang)语言轻量级MVC框架。用于构建快速,可扩展和健壮的数据库驱动Web应用。 特性 
Postgres, MySQL和Foundation 数据库支持. 
模块化(你可以选择要使用的组件) 
中间件的支持。所有爱alice兼容的中间件开箱的。 
Gopher spirit (write golang, use all the golang libraries you like) 
Lightweight. Only MVC. 
Multiple configuration files support (currently json, yaml and toml) 
Overview 
utronis a lightweight MVC framework. It is based on the premise of simplicity, relevance and elegancy. 
Simplicity. The design is simple, easy to understand and less layers from the standard library. It is in the spirit of the project that, users should understand the whole framework in a single day. 
Relevance.utrondoesn't assume anything. We focus on things that matter, this way, we are able to achieve good maintenance and keeping the system well organized, well planned and sweet like. 
Elegancy.utronuses golang best practises. We are not afraid of heights, its just that we need a parachute in our backpack. The source code is heavily documented, any trick should be well explained and well tested. 
Motivation 
After two years of playing with golang. I have looked on some of my projects and asked myself, how golang is that? 
So,utronis my reimagination of lightweight MVC, that maintains the golang spirit, and works seamlessly with the current libraries. 
Installation 
$ go /gernest/utron The MVC 
There is nothing revolutionary about MVC thatutronbrings on the table. 
M is for models, it is the data structures that helps in data persistance, utron uses an already established Object Relational Mapper for golang . So if you are familiar with gorm then you are good on the M part. 
V is for Views. Views are templates, that renders the final output.utronuses golang standard templates. so you don't have to learn anything new, just the text/template package to master views. 
C is for controllers. This is where the aplication logic stands, in order to achieve modularity, there are some facts that utron enforces to controllers. This subject is explained in more details below. 
With the power of composition and inheriance,utronachieves a beautiful MVC workflow. I recommend you read the source code, it is well documented so as to demistify any magical unicorns. 
We will create a TODO List application inutronto explore all components that makesutronMVC tick the source code of the final application is included in this repository and can be found here
TODO list application withutron 
Project structure 
This is the structure of thetodolist application that will showcase how you can build web apps withutron. 
├── config
├── app.json
├── app.toml
└── app.yml
├── controllers
└── todo.go
├── models
└── todo.go
├── static
└── todo.css
├── views
├── error.html
└── index.html
└── main.go
5 directories, 9 files
I have included three configuration files for clarity, but you are better off with just one. 
Configurations 
utron support yaml, json and toml configurations files. In our todo app, we put the configuration files in the config directory. I have included all three formats for clarity, you can be just fine with either one of them. 
utronsearches for a file namedapp.json, orapp.ymlorapp.tomlin the config directory. The first to be found is the one to be used. 
This is the content ofconfig/app.jsonfile 
{ "app_name": "utron web app", "base_url": "http://localhost:8090", "port": 8090, "verbose": false, "static_dir": "static", "view_dir": "views", "database": "postgres", "database_conn": "postgres://postgres:postgres@localhost/todo" }
setting 
details 
app_name 
application name 
base_url 
the base url to use in your views 
port 
port number where the server will be listening to 
verbose 
true value will make every state information logged to stdout 
static_dir 
directory to serve static files e.g images, js or css 
view_dir 
directory to look for views 
database 
the name of the database you use, e.g postgres, mysql, foundation 
database_conn 
connection string to your database 
If you haven't specified explicitly the location of the configuration directory, then it defaults to the directory namedconfigin the current working directory. 
Models 
library as its Object Relational Mapper. So, you won't need to learn anything fancy. In our todo app, we need to defineTodomodel that will be used to store our todo details. 
In the filemodels/todo.gowe define our todo model like this 
package models
import (
"time"
"/gernest/utron"
type Todo struct {
`schema: "-"`
`schema:"body"`
CreatedAt time.Time `schema:"-"`
UpdatedAt time.Time `schema:"-"`
func init() {
utron.RegisterModels(&Todo{})
}Notice that, we need to register our model, by callingutron.RegisterModels(&Todo{})in theinitfunction otherwiseutronwon't be aware of the model. 
utronwill automatically create the tabletodosif it doesn't exist yet. 
Don't be confused by theschematag, I just added them since we will use
package to decode form values(this has nothing to do withutron, you can use whatever form library you fancy) 
Controllers 
utroncontrollers are structs that implement theControllerinterface. To help makeutronusable,utronprovides aBaseControllerwhich implements theControllerinterface and offers additional conveniences to help in composing reusable code. 
You get all the benefits ofBaseControllerby embeding it in your struct. ourTODOController is in thecontroller/todo.go 
package controllers
import (
"net/http"
"strconv"
"/gernest/utron"
"/gernest/utron/fixtures/todo/models"
"/gorilla/schema"
var decoder = schema.NewDecoder()
type TODO struct {
*utron.BaseController
Routes []string
func (t *TODO) Home() {
todos := []*models.Todo{}
t.Ctx.DB.Order("created_at desc").Find(&todos)
t.Ctx.Data["List"] = todos
t.Ctx.Template = "index"
t.HTML(http.StatusOK)
func (t *TODO) Create() {
todo := &models.Todo{}
req := t.Ctx.Request()
req.ParseForm()
if err := decoder.Decode(todo, req.PostForm); err != nil {
t.Ctx.Data["Message"] = err.Error()
t.Ctx.Template = "error"
t.HTML(http.StatusInternalServerError)
return
t.Ctx.DB.Create(todo)
t.Ctx.Redirect("/", http.StatusFound)
func (t *TODO) Delete() {
todoID := t.Ctx.Params["id"]
ID, err := strconv.Atoi(todoID)
if err != nil {
t.Ctx.Data["Message"] = err.Error()
t.Ctx.Template = "error"
t.HTML(http.StatusInternalServerError)
return
t.Ctx.DB.Delete(&models.Todo{ID: ID})
t.Ctx.Redirect("/", http.StatusFound)
func NewTDDO() *TODO {
return &TODO{
Routes: []string{
"/;Home",
"/Create",
"/delete/{id};Delete",
func init() {
utron.RegisterController(NewTDDO())
Note we registered our controller by callingutron.RegisterController(NewTDDO())in theinitfunction so as to makeutronaware of our controller. See Routing section below for more explanation of what the controller is doing.项目主页:
免责声明:本站部分内容、图片、文字、视频等来自于互联网,仅供大家学习与交流。相关内容如涉嫌侵犯您的知识产权或其他合法权益,请向本站发送有效通知,我们会及时处理。反馈邮箱&&&&。
学生服务号
在线咨询,奖学金返现,名师点评,等你来互动

我要回帖

更多关于 golang 游戏框架 的文章

 

随机推荐