Serialization format common to node.js and ActionScript?

Some of my friends are developing a game, and I help them by implementing a game backend server. The game is written in Flash, and I plan to develop a server in node.js, because (a) it will be a cool project to study node.js and (b) it is fast, which is important for games.

The server architecture is based on messages sent between the server and the client (such as the Minecraft server protocol). The format of the message, which I still represent bytes (packet type), two bytes (message length) and many bytes (message data, which are a mapping of key-value pairs). The problem is that I really don't want to develop my own serialization format (because, although I probably could, implementing this would be a pain compared to using an existing solution).

Unfortunately, I am having problems finding a good candidate for the serialization format of these messages.

  • The Remoting format for ActionScript may work, but I don't like it.
  • JSON has support in node.js (obviously) and in ActionScript, but it is also text-based, and I would prefer a binary to increase speed.
  • MessagePack looked like a good candidate, but I cannot find an ActionScript implementation. (There is one called as3-msgpack in Google Code, but I get weird errors and cannot access it.)
  • BSON has an ActionScript implementation, but support for node.js is in addition to their MongoDB library (and I plan to use Redis).

So, can anyone suggest any other serialization formats that I might have missed? Or should I just stick to one of them (or collapse on my own)?

+4
source share
5 answers

Not because HTTP supports gzipped content? Just use JSON and gzip content when you submit it. The time spent on gzipping is more than being restored by reducing the latency of the transmission.

Read more about this in gzip with Actionscript . On node.js, I think gzip-compress is pretty popular.

+1
source

Actually, if I were in your place, I would use two methods and their time. Use JSON because this is common and easy to do. But instead add AMQP and compare them. If you want to scale this out massively, you may find that AMQP makes things easier. Also. Message Queueing is just such a nice fit in the world view of node.js.

AMQP in Actionscript and someone does similar on node. JS .

+1
source
+1
source

If you wanted to, you could create your client-side JavaScript API and use JSON as the data exchange format, and then call ExternalInterface AS to communicate with the client-side JavaScript API, which will make for an elegant server-side solution.

It is worth noting that Flash Player has built-in support for decompressing gzip compressed data. It might be worth compressing some of your JSON objects, such as localized string tables, game configuration data, etc., which can grow up to several hundred kilobytes, but only load once when the game loads.

0
source

I am working on a version of MessagePack for AS3. In the current version, it performs the basic (encoding / decoding). Flow planning for the future. Check out the project page: https://github.com/loteixeira/as3-msgpack

0
source

Source: https://habr.com/ru/post/1340721/


All Articles