org.moock.unity.core
Interface ClientServices


public interface ClientServices

Interface for handling services associated with Clients.

Author:
Derek Clayton
See Also:
Services

Method Summary
 void broadcastClient(java.lang.String message)
          Broadcasts to a client.
 java.util.HashMap getAllAttributes()
          Returns a HashMap keyed by scope containing HashMaps keyed by Attribute name of all of the attributes.
 java.util.HashMap getAllAttributes(java.lang.String fqRoomID)
          Returns a HashMap containing all of the attributes for the client.
 java.util.HashMap getAllSharedAttributes()
          Returns a HashMap keyed by scope containing HashMaps keyed by Attribute name of all of the attributes flagged as shared for the client.
 java.lang.Object getAttribute(java.lang.String name, java.lang.String fqRoomID)
          Returns objects from the clients .
 java.lang.String getClientID()
          Get the ID for the client.
 long getConnectToServerTime()
          Retrieves the time the Client connected to the server.
 java.lang.String getIP()
          Gets the ip of this client.
 java.util.HashSet getRoomList()
          Returns a list of RoomID's of Rooms the Client is in.
 java.util.HashMap getSharedAttributes(java.lang.String fqRoomID)
          Returns a HashMap containing the attributes flagged as shared for the client for the Room fqRoomID.
 boolean isDying()
          Returns true if the client has been shutdown.
 boolean isLoggedIn()
          Gets if this Client has been logged in set by AttributePersistence.
 int joinRoom(java.lang.String roomID)
          Attempts to have client join room with ID roomID.
 void killClient()
          Removes the client from the server.
 int leaveRoom(java.lang.String roomID)
          Removes the client from the room with ID roomID.
 int loginRoom(java.lang.String roomID, java.util.ArrayList args)
          Attempts to have client join room with ID roomID.
 void removeAttribute(java.lang.String name, java.lang.String fqRoomID)
          Removes an object from the clients .
 void setAttribute(java.lang.String name, java.lang.Object obj, java.lang.String fqRoomID, int flags)
          Adds an object to the client's custom .
 

Method Detail

loginRoom

public int loginRoom(java.lang.String roomID,
                     java.util.ArrayList args)
              throws org.moock.unity.core.exception.RoomNotFoundException,
                     org.moock.unity.core.exception.NamespaceNotFoundException
Attempts to have client join room with ID roomID.
Returns:
0 - Room.SUCCESS: authentication succeeded and the client joined the room

joinRoom

public int joinRoom(java.lang.String roomID)
             throws org.moock.unity.core.exception.RoomNotFoundException,
                    org.moock.unity.core.exception.NamespaceNotFoundException
Attempts to have client join room with ID roomID.
Returns:
0 - Room.SUCCESS: authentication succeeded and the client joined the room

leaveRoom

public int leaveRoom(java.lang.String roomID)
              throws org.moock.unity.core.exception.RoomNotFoundException,
                     org.moock.unity.core.exception.NamespaceNotFoundException
Removes the client from the room with ID roomID.
Returns:
0 - Room.SUCCESS: the client left the room

broadcastClient

public void broadcastClient(java.lang.String message)
Broadcasts to a client.
Parameters:
message - the message to send

getClientID

public java.lang.String getClientID()
Get the ID for the client. The ID is a unique integer assigned when the client is created.
Returns:
ID unique id of the client

killClient

public void killClient()
Removes the client from the server.

getRoomList

public java.util.HashSet getRoomList()
Returns a list of RoomID's of Rooms the Client is in.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object obj,
                         java.lang.String fqRoomID,
                         int flags)
Adds an object to the client's custom .
Parameters:
name - the name under which to store the object
obj - the object to store
fqRoomID - the fully qualified id of the room this property should attached to, null for global
flags - 0=none,1=shared,2=persistent,3=shared and persistent

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     java.lang.String fqRoomID)
Returns objects from the clients .
Parameters:
name - the name under which the desired object has been stored
fqRoomID - the fully qualified id of the room this property is attached to, null for global
Returns:
object stored under name

removeAttribute

public void removeAttribute(java.lang.String name,
                            java.lang.String fqRoomID)
Removes an object from the clients .
Parameters:
name - the name of the object to remove
fqRoomID - the fully qualified id of the room this property is attached to, null for global

getAllAttributes

public java.util.HashMap getAllAttributes()
Returns a HashMap keyed by scope containing HashMaps keyed by Attribute name of all of the attributes.

getAllAttributes

public java.util.HashMap getAllAttributes(java.lang.String fqRoomID)
Returns a HashMap containing all of the attributes for the client.
Parameters:
fqRoomID - the fully qualified id of the room this property is attached to, null for global

getSharedAttributes

public java.util.HashMap getSharedAttributes(java.lang.String fqRoomID)
Returns a HashMap containing the attributes flagged as shared for the client for the Room fqRoomID.
Parameters:
fqRoomID - the fully qualified id of the room this property is attached to, null for global

getAllSharedAttributes

public java.util.HashMap getAllSharedAttributes()
Returns a HashMap keyed by scope containing HashMaps keyed by Attribute name of all of the attributes flagged as shared for the client.

getIP

public java.lang.String getIP()
Gets the ip of this client.
Returns:
ip this client's ip

isLoggedIn

public boolean isLoggedIn()
Gets if this Client has been logged in set by AttributePersistence.

isDying

public boolean isDying()
Returns true if the client has been shutdown. The socket of this client should no longer reliably be considered available. Note that once this value returns false it always returns false and should only be used to execute (or avoid) certain code on this condition. However, if the value returns true there is no guarantee when it may become false. In other words, a client that has isDying() return true may be shutdown anytime after the check including during code inside the condition check.

getConnectToServerTime

public long getConnectToServerTime()
Retrieves the time the Client connected to the server.
Returns:
the difference, measured in milliseconds, between the time the Client connected to the server and midnight, January 1, 1970 UTC.