Developing a Custom Protocol
Overview
When a Client wants to communicate with Unity 2 Multiuser Server (U2MS) they must first agree on a
Protocol or an agreed upon format for the Messages. By default U2MS assumes this to be
Unity Procedure Call (UPC). However, by creating a custom MessageRouter you can use
any format you like. Some examples might be:
character delimited: "myroom|sendmessage|hi there"
positional: "myroom01hithere" (first 6 characters are room, next 2 are method, remainder is argument for the method)
You could also create MessageRouters for common formats such as XML-RPC.
MessageRouter
To create a new Protocol for U2MS you must create a new MessageRouter. The MessageRouter is responsible for
two things. First, all incoming messages are passed to the MessageRouter to determine which Room the message
should be passed to. Second, the MessageRouter is responsible for formatting Messages which may be needed
internally by U2MS. For example, the MessageRouter determines if the ClientID should be automatically sent
to each Client that connects and it creates the actual Message to be sent since U2MS knows
nothing about the protocol being used.
Creating A MessageRouter
Step 1
Implement the MessageRouter interface.
Step 2
Fill in all the interface methods as necessary. See the javadoc for more details.
Step 3
Specify the MessageRouter to be used in uconfig.xml. For example, if you create a new MessageRouter called
myMR.TabDelimitedMessageRouter:
<MESSAGE_ROUTER>myMR.TabDelimitedMessageRouter</MESSAGE_ROUTER>
See configuration for more details.