Skip to content

Pomelo 0.2到0.3升级指南

chang edited this page Mar 6, 2013 · 11 revisions

##servers.json配置文件的修改

随着Pomelo支持协议的增多,配置文件原先定义的wsPort(代表websocket port)已不适用,现调整为clientPort。并新增一个字段frontend来标识该服务器是否是前端服务器,前端服务器 必须 设置该字段为true,后端服务器可以不设置或设置成false。

lordofpomelo为例,servers.js文件修改如下。

connector服务器配置:

"connector": [
  {"id": "connector-server-1", "host": "127.0.0.1", "port": 3150, "clientPort": 3010, "frontend": true},
  {"id": "connector-server-2", "host": "127.0.0.1", "port": 3151, "clientPort":3011, "frontend": true}
]

gate服务器配置:

"gate": [
  {"id": "gate-server-1", "host": "127.0.0.1", "clientPort": 3014, "frontend": true}
]

服务器代码中有依赖到配置信息wsPort的地方也需要做相应的调整。lordofpomelo中的gateHandler中的res.wsPort需要改为res.clientPort

##connector配置

0.2中基于socket.io connector的服务器代码可以无需修改就能使用。

如要使用支持socket和websocket的connector,在app.js配置指定使用hybridconnector即可。使用例子如下:

app.configure('production|development', 'connector', function(){
  app.set('connectorConfig', {
    connector: pomelo.connectors.hybridconnector,
    heartbeat: 3,
    useDict: true,
    useProtobuf: true,
    checkClient: function(type, version) {
    	// check the client type and version then return true or false
    },
    handshake: function(msg, cb){
      cb(null, {/* message pass to client in handshake phase */});
    }
  });
});

更详细的信息和多connector的共存请参考Pomelo 0.3新特性文档。

##route字典压缩配置

TODO

##protobuf压缩配置

TODO

##web客户端build配置

TODO

Clone this wiki locally