I use json as the serialize format that runs on websocket in my web game at first. But there are so much redundancy in json. So I want to find a more effective format to serialize my object.
And then I found protojs(https://github.com/sirikata/protojs) which implements protobuf in javasc开发者_JS百科ript. But its encoding performance is so poor (about 20+ times of json) since javascript dose not support type cast and it has to do a lot math operations to convert the primary data type (such as double) to bytes to do the protobuf encoding. The result turns out to be that request in protojs is much slower than in json.
Is there any good idea to improve the efficiency of data communication on websocket in web game?
I recently attended onGameStart (write-up here) and Rob Hawkes of Mozilla and Rawkets fame mentioned BSON (Binary JSON). However, he did say that he wasn't 100% sure if it improved efficiency.
精彩评论