8

参考ZeroMQ改进服务器

 2 years ago
source link: https://www.skywind.me/blog/archives/962
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

参考ZeroMQ改进服务器

今天参考 ZeroMQ的观点为我们的网络模块增加了一个“订阅模式”,及客户端包头用四字节表示,低24位为长度,高八位为“消息分类”。后端连接网络层的若干“频道”可以根据自己的喜好订阅“分类消息”,那么客户端发送该分类消息到网络层的时候,将会被抄送到订阅过该分类的频道。每个频道还可以订阅若干系统消息,比如连接开始、断开、时钟等等。

我们的服务器自2004年底到现在,一直是网络和逻辑分离在不同的进程(主机)中间,网络模块可以连接多个提供服务的“频道”,只是配合休闲游戏的模型,当前只有一个频道可以和特定玩家进行交互。不过其基于多频道的模型使得这次改进很容易,改了三个小时,又跑了几个小时的测试用例,基本通过。

以后交易,聊天,逻辑等,都可以分布在不同的频道里面同时为玩家提供服务了。

184 total views, 3 views today

I like thisUnlike LikeI dislike thisUndislike 


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK