org.moock.unity.core
Interface MessageRouter


public interface MessageRouter

MessageRouter Objects which are responsible for routing messages within the Unity server must implement this interface. Messages sent internally by the Server are also formed through this Object.

Author:
Derek Clayton

Method Summary
 void cleanup()
          Called when the server is shut down.
 java.lang.String getClientIDMessage(java.lang.String clientID)
          Returns a String that is sent to the Client when they connect to the server.
 java.lang.String getConnectErrorBannedMessage()
          Returns a String that is sent to the Client when they connect to the server but their ip has been banned.
 java.lang.String getConnectErrorServerFullMessage()
          Returns a String that is sent to the Client when they connect to the server but the server maximum clients has been reached.
 java.lang.String getTargetRoom(Message message)
          This method is called by the server to determine to which room a message should be routed.
 boolean init()
          Called on startup when the object is created to perform any initialization needed.
 

Method Detail

init

public boolean init()
Called on startup when the object is created to perform any initialization needed.
Returns:
true to indicate the initialization occurred correctly, false otherwise

getTargetRoom

public java.lang.String getTargetRoom(Message message)
This method is called by the server to determine to which room a message should be routed. By default Unity server assumes messages are sent using Unity Procedure Call (UPC). If your applications use a different protocol (eg. XML-RPC or non-XML) then you will have to create an object which implements MessageRouter and declare that object in server.xml.
Parameters:
message - the message to be routed.
Returns:
id the roomid of the target room or null if message should be ignored

getClientIDMessage

public java.lang.String getClientIDMessage(java.lang.String clientID)
Returns a String that is sent to the Client when they connect to the server. Return null to not send anything.

getConnectErrorBannedMessage

public java.lang.String getConnectErrorBannedMessage()
Returns a String that is sent to the Client when they connect to the server but their ip has been banned. Return null to not send anything.

getConnectErrorServerFullMessage

public java.lang.String getConnectErrorServerFullMessage()
Returns a String that is sent to the Client when they connect to the server but the server maximum clients has been reached. Return null to not send anything.

cleanup

public void cleanup()
Called when the server is shut down. Release any resources and other cleanup code here.