I have been looking for a while on the web for a library that will serialize messages down to native objects that can be used with intellisense, and after a lot of looking around I decided to build my own.
The library includes a RobotLegs extension that you can install and use out of the box, the extension simplifies the setup process.
This library is far from complete, please report any bugs you might find, but this is the first version, any support is greatly welcome!
Features
- cascading down to child types of a parent message type to determine the wright choice based on the properties provided in the message.
- serialization of dates from either a given format, or a timestamp, dates currently only support number formatting and no timezones, altho this is planed for near future.
- Vector type serialization, the library can serialize Arrays directly to Vectors of a given type, it will also cascade down to the proper child if the Vector type is a base class that has children, for example: items:Vector.
- serialization of Boolean either as string "true"/"false", number or other
- processing of the messages in separate message processors to better separate the logic of processing the message.
- checkField / checkValue matching for a given message to any given message processor, by adding the check field and check value in the metadata tags of the MessageHandler function you can link this processor to a message, this is useful for sockets, for example if the socket sends a message like so {cmd:"UpdateFriends", data:{...}}, you could define the message handler as such [MessageHandler(checkField="cmd", checkValue="UpdateFriends", messageRoot="data")] this will link this MessageHandler to that message. When calling process on your controller, you can have multiple processors linked to a same message, each processor can have a different checkField to match against in the same message, and checkFields don't have to be at the root of the message. For example you can have a checkField like so: "user.type" meaning that the type field will be checked inside the user object against the checkValue.
- the messageRoot option allows you to define what field inside the message object will have the proper form to be processed by the given message processor into the given message type, this allows you to easily send the same data update in multiple messages with the same root, for example you could have a field called user that you send on every API request in different messages, to update the user stats, and user contains a check field cmd that you can reference against to extract the user object from all the messages easily.
- SerializableData type, this is a type that contains serialize, and deSerialize methods, as well as a convenience method of clone, you can use this type to serialize or deserialize your data manually without using the AS3MP setup for message processors, also even if you are using the AS3MP standard way of processing messages, it is recommended that your message classes extend from the SerializableData type as it will improve the parsing speed slightly.
- RobotLegs extension, featuring full support for dependency injection into message processors, enabling ease of use in message processors with all of your injected objects.
NOTE: in order to cascade down to child types, you must register the child types in the messagecontroller or in messagecontrol if you are using the robotlegs extension.
In a nutshell this library will help improve your organization for processing server messages, I have used it in a large scale commercial project the past year, with no performance loss problems.
Enjoy!