The Perl Message implementation uses 'Message
' objects defined in
Message.pm. A Message object can also contain zero to four
'MessageArg
' objects. The message IDs are stored in hashes which
you can import into your namespace by doing something like 'use
MSMessages qw(:all)
'. The message arg types 'Integer
',
'String
', and 'Binary
' are all defined when you
'use Messages
'. The arg type 'ClientKey
' is defined
when you 'use ClientKey
'. I know it's naughty of me to define
more than one object in a .pm file, but, darnit, message arg objects are small
and trivial. As a side note: there is no real difference between
'MessageArg::String
' and 'MessageArg::Binary
' except
what they return in their 'toString
' methods. The "text" you can
send to clients is generally not bounded to being a string (the multiplexer
won't care either way).
To compose a message, you would use the 'newFromArgs
' method
(even if you do not have any arguments, you at least have a message id). Each
'MessageArg
' type contains a 'newFromVal
' method,
so, if you wanted to, say, send text to a client (for which you must have a
'ClientKey
' object), you would do this:
|
And then '$message->getPacked
' would give you the literal binary
content to send to the multiplexer. There's a fairly good chance (unless you
define your own argument types and expect them to work), you could use
'guessFromArgs
' instead of 'newFromArgs
' and pass
the arguments directly, i.e.:
|
Receiving a message is slightly more tricky. As I haven't finished the parse method, I can't really finish this section yet.
This project is hosted by sourceforge.net: | project homepage | silver's homepage |