UPC


Overview

UPC stands for Unity Procedure Call. It is a simple communication protocol for invoking methods on the server. A UPC call looks like the following:
<UPC>
  <ROOMID>targetRoomID</ROOMID>
  <METH>method</METH>
  <ARGS>
    <ARG>arg1</ARG>
    <ARG>arg2</ARG>
    ...
    <ARG>argn</ARG>
  </ARGS>
</UPC>
targetRoomID is the ID of the Room which should handle this message.
method is the method you would like to invoke on the Room.
You may also specify any number of arguments (ARG) within the ARGS tag that you would like passed to the method. All arguments are sent as String and any conversion to other types must be done within the Room.

UPCRoom

UPCRoom is a Room which knows how to process UPC. It's fully qualified class name is org.moock.unity.core.upc.UPCRoom. If you want to code a server side Room based on UPC you can make use of the functionality already in UPCRoom by extending it rather than org.moock.unity.core.Room as usual. If the UPCRoom cannot process a message itself it passes that message to it's method handleMessage which you can override to add your own handlers.

UPCMessage

UPCMessage is an Object representation of a UPC message. It is an easier form to work with than a raw String. In general, you parse an incoming String to a UPCMessage for processing (see UPCParser). Then generate an outgoing UPCMessage and convert it to a String when you want to broadcast it (see UPCBuilder).

UPCParser

UPCParser is used to parse a String of UPC and convert it to a UPCMessage Object. It has 1 static method parse(). Example:

UPCMessage upcMessage = UPCParser.parse(myUPCString);

UPCBuilder

UPCBuilder is used to convert a UPCMessage and convert it to a String Object typically to send to Clients. It has 1 static method build(). Example:

broadcastRoom(UPCBuilder.build(myUPCMessage));