tag:robotlegs.tenderapp.com,2009-10-18:/discussions/solutions/1128-finally-a-message-processing-libraryRobotlegs: Discussion 2014-01-22T15:29:02Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/299403542013-11-12T14:39:32Z2013-11-13T07:20:32ZFinally a Message Processing library!<div><p>Hey guys, 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.<br>
The library includes a RobotLegs extension that you can install and
use out of the box, the extension simplifies the setup process.<br>
This library is far from complete, please report any bugs you might
find, any support is greatly welcome!</p>
<p><strong>Features</strong></p>
<ul>
<li>cascading down to child types of a parent message type to
determine the wright choice based on the properties provided in the
message.</li>
<li>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.
<ul>
<li>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.</li>
<li>serialization of Boolean either as string "true"/"false",
number or other</li>
<li>processing of the messages in separate message processors to
better separate the logic of processing the message.</li>
<li>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.</li>
<li>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.</li>
<li>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.</li>
<li>RobotLegs extension, featuring full support for dependency
injection into message processors, enabling ease of use in message
processors with all of your injected objects.</li>
</ul>
</li>
</ul>
<p>NOTE: in order to parse from parent types down to the most
logical child types, for parent classes with multiple children, you
must register the child types in the messagecontroller or in
messagecontrol if you are using the robotlegs extension.</p>
<p>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.</p>
<p>Enjoy!</p>
<p><a href=
"https://github.com/vankovilija/as3mp">https://github.com/vankovilija/as3mp</a></p>
<p>PS. I know that documentation is poor at this point, more docs
are coming soon, as well as a wiki, stand by :)</p></div>vankov.ilijatag:robotlegs.tenderapp.com,2009-10-18:Comment/299403542013-11-13T07:21:10Z2013-11-13T07:21:10ZFinally a Message Processing library!<div><p>Wow, it looks great! Thank you for sharing it with us.</p></div>Ondina D.F.