Pomelo的Protobuf
pomelo的protobuf实现,借助了javascript的动态性,使得应用程序可以在运行时解析proto文件,不需要进行proto文件的编译。pomelo的实现中,为了更方便地解析proto文件,使用了json格式,与原生的proto文件语法是相通的,但是是不相同的。用户定义好客户端以及服务端的通信所需要的信息格式的proto文件,服务端的proto配置放在config/serverProtos.json中,客户端的proto配置放在config/clientProtos.json。如果在其配置文件里,配置了所有类型的proto信息,那么在通信过程中,将会全部使用二进制的方式对消息进行编码; 如果没有定义某一类消息相应的proto,pomelo还是会使用初始的json格式对消息进行编
// clientProtos.json
{
"chat.chatHandler.send": {
"required string rid": 1,
"required string content": 2,
"required string from": 3,
"required string target": 4
}, "connector.entryHandler.enter": {
"required string username": 1,
"required string rid": 2
}, "gate.gateHandler.queryEntry": {
"required string uid": 1
}
} // serverProtos.json
{
"onChat": {
"required string msg": 1,
"required string from": 2,
"required string target": 3
}, "onLeave": {
"required string user": 1
}, "onAdd": {
"required string user": 1
}
}
在app.js中配置:
app.configure('production|development', 'connector', function() {
app.set('connectorConfig', {
connector: pomelo.connectors.hybridconnector,
heartbeat: 3,
useDict: true,
useProtobuf: true //enable useProtobuf
});
});
app.configure('production|development', 'gate', function(){
app.set('connectorConfig', {
connector : pomelo.connectors.hybridconnector,
useDict: true,
useProtobuf: true //enable useProtobuf
});
});
Pomelo的Protobuf的更多相关文章
- pomelo 协议
分析的是hybridconnector,使用的chatofpomelo-websocket(pomelo为0.7.0) 參考:https://github.com/NetEase/pomelo/wik ...
- pomelo RPC调用时新增字段缺失
接触pomelo开发一个月,正式开始参与项目开发有10天,遇到很多细节的坑,今天讲讲标题:后端服务器节点之间的rpc调用过程中,返回的数据中新增字段缺失问题. 先讲结果:原因是该rpc调用已经采用了p ...
- 转: 基于netty+ protobuf +spring + hibernate + jgroups开发的游戏服务端
from: http://ybak.iteye.com/blog/1853335 基于netty+ protobuf +spring + hibernate + jgroups开发的游戏服务端 游戏服 ...
- python通过protobuf实现rpc
由于项目组现在用的rpc是基于google protobuf rpc协议实现的,所以花了点时间了解下protobuf rpc.rpc对于做分布式系统的人来说肯定不陌生,对于rpc不了解的童鞋可以自行g ...
- Protobuf使用规范分享
一.Protobuf 的优点 Protobuf 有如 XML,不过它更小.更快.也更简单.它以高效的二进制方式存储,比 XML 小 3 到 10 倍,快 20 到 100 倍.你可以定义自己的数据结构 ...
- java netty socket库和自定义C#socket库利用protobuf进行通信完整实例
之前的文章讲述了socket通信的一些基本知识,已经本人自定义的C#版本的socket.和java netty 库的二次封装,但是没有真正的发表测试用例. 本文只是为了讲解利用protobuf 进行C ...
- 在Wcf中应用ProtoBuf替代默认的序列化器
Google的ProtoBuf序列化器性能的牛逼已经有目共睹了,可以把它应用到Socket通讯,队列,Wcf中,身为dotnet程序员一边期待着不久后Grpc对dotnet core的支持更期待着Wc ...
- protobuf的编译安装
github地址:https://github.com/google/protobuf支持多种语言,有多个语言的版本,本文采用的是在centos7下编译源码进行安装. github上有详细的安装说明: ...
- 编译protobuf的jar文件
1.准备工作 需要到github上下载相应的文件,地址https://github.com/google/protobuf/releases protobuf有很多不同语言的版本,因为我们需要的是ja ...
随机推荐
- php运行机制初探
对于这个结果我也很吃惊,但是事实就在眼前,没办法啊,那么到底为什么会有这样的效果呢,咱们继续一探究竟: *.php(php代码) -----Scanner(zend引擎逐行扫描变为zend可以识别的语 ...
- mysql 本地操作
先把数据库传到根目录 再直接导入 没有50M限制root@b101 [/home/user/www]# mysql -uusername_007li -ppasswd -D dbname_li12d ...
- 只有mdf 没有 日志 恢复数据库
1.先建一个与你要恢复的数据库名称一样的数据库.2.停止sql server,把你的数据库替换这个数据库.3.重启sql server,把数据库设置为紧急状态. sp_configure 'allo ...
- JAVA基础--异常
异常的分类: 1. Throwable: 根类 1) Error:系统错误, 由java虚拟机生成并抛出, 无法处理 2) Exception: 所有异常类的父类, 可以处理的错误, 可以catch到 ...
- CodeForces 614B Gena's Code
#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm& ...
- (中等) CF 311B Cats Transport,斜率优化DP。
Zxr960115 is owner of a large farm. He feeds m cute cats and employs p feeders. There's a straight r ...
- CodeForces 620A Professor GukiZ's Robot
水题 #include<cstdio> #include<cstring> #include<cmath> #include<stack> #inclu ...
- HDU 4169 UVALive 5741 Wealthy Family
树形背包.DP递推的思路很简单.... 但是由于节点有15万个,先不论空间复杂度,这样开dp数组 dp[150000+10][300+10],如果初始化是memset(dp,-1,sizeof dp) ...
- 鸽笼原理的运用HDU1205
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1205 题目解析:开始没看清题,WA了一发,以为只要最大的次大的差2就是NO,后来仔细看过之后才发现,, ...
- Mysql中Insert into xxx on duplicate key update问题
要点:Insert into xxx on duplicate key update可以在唯一索引重复的情况下,进行更新操作. (1) 插入里边的字段应该只有一个 唯一索引: ...