You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pomelo 0.4 makes structural changes to support friendly custom communication protocol, and provides custom data transmission strategy for different situations.
Custom protocol
Implementation of server side
Pomelo 0.4 makes a more detailed protocol division to support more flexible custom feature. The main structure is as follow chart:
We add the protocol layer to encode/decode data packages between the upper layer and under layer. Protocol layer is mainly in charge of encoding and decoding transmission data for upper layer, and is associated with specific connector. Hybridconnector is responsible for dealing with Message layer data, and sioconnector is responsible for dealing with data from socket.io layer.
Encoding and decoding algorithm in protocol layer can be custom made by passing it to connector, example code is as follow:
varencode=function(reqId,route,msg){// do some customized encode with reqId, route and msgreturnresult;// return encode result};vardecode=function(msg){// do some customized decode with msgreturnresult;// return decode result};app.configure('production|development','connector',function(){app.set('connectorConfig',{connector : pomelo.connectors.hybridconnector,encode: encode,decode: decode});});
When data comes to connector, the corresponding encode and decode methods will be invoked.
encode(reqId, route, msg) - means encoding reqId, route and msg.