net.user1.union.api
Interface Client

All Superinterfaces:
AttributeHolder, EventProducer

public interface Client
extends AttributeHolder, EventProducer

A client is a single user in the system who has connected to the server.


Field Summary
static String ATTR_CONNECTIONTYPE
           
static String ATTR_CONNECTTIME
           
static String ATTR_GATEWAYID
           
static String ATTR_GATEWAYTYPE
           
static String ATTR_IP
           
static String ATTR_LASTACTIVE
           
static String ATTR_SESSIONID
           
static String ATTR_TYPE
           
static String ATTR_UID
           
static String ATTR_UPC_VERSION
           
static String ATTR_UPDATE_LEVEL
           
static String ATTR_USERAGENT
           
 
Method Summary
 Account getAccount()
          Get the Account for the client.
 String getClientID()
          Get the ID for the client.
 long getConnectToServerTime()
          Deprecated. use getAttribute
 long getLastActive()
          Returns the System time (System.timeCurrentMillis()) the client was last active (i.e.
 Set<String> getRoomList()
          Returns the room ID's of Rooms the Client is in.
 String getUID()
          Deprecated. use getAttribute
 Integer getUpdateLevels(String roomID)
          Return the update levels for set for the given roomID.
 String getUserID()
          This is a convenience method for retrieving the userID of the client without having to do null check on the client.
 boolean isLoggedIn()
          Returns true if the client has logged in.
 boolean isShutdown()
          Returns true if shutdown has been called on the client.
 String joinRoom(String roomID, String password)
          Attempts to have client join a room.
 String leaveRoom(String roomID)
          Removes the client from a room.
 String login(String userID, String password)
          Login the client to the server.
 String logoff(String userID, String password)
          Logoff the client from the server.
 String observeRoom(String roomID, String password)
          Attempts to have the client observe a room.
 void sendMessage(String message, String... args)
          This generates a u7 which is sent to the client.
 void setUpdateLevels(String roomID, int levels)
          Sets the update levels for the room.
 void shutdown()
          Removes the client from the server after sending any messages currently queued to be sent.
 void shutdown(boolean sendRemainingMessages)
          Removes the client from the server.
 String stopObservingRoom(String roomID)
          Stop observing a room.
 
Methods inherited from interface net.user1.union.core.attribute.AttributeHolder
getAttribute, getAttribute, getAttributes, getAttributes, getAttributesByScope, getAttributeValue, getAttributeValue, onChangeAttribute, onRemoveAttribute, removeAttribute, removeAttribute, setAttribute
 
Methods inherited from interface net.user1.union.core.event.EventProducer
addEventListener, removeEventListener
 

Field Detail

ATTR_UID

static final String ATTR_UID
See Also:
Constant Field Values

ATTR_CONNECTTIME

static final String ATTR_CONNECTTIME
See Also:
Constant Field Values

ATTR_SESSIONID

static final String ATTR_SESSIONID
See Also:
Constant Field Values

ATTR_GATEWAYID

static final String ATTR_GATEWAYID
See Also:
Constant Field Values

ATTR_GATEWAYTYPE

static final String ATTR_GATEWAYTYPE
See Also:
Constant Field Values

ATTR_CONNECTIONTYPE

static final String ATTR_CONNECTIONTYPE
See Also:
Constant Field Values

ATTR_TYPE

static final String ATTR_TYPE
See Also:
Constant Field Values

ATTR_USERAGENT

static final String ATTR_USERAGENT
See Also:
Constant Field Values

ATTR_UPC_VERSION

static final String ATTR_UPC_VERSION
See Also:
Constant Field Values

ATTR_IP

static final String ATTR_IP
See Also:
Constant Field Values

ATTR_LASTACTIVE

static final String ATTR_LASTACTIVE
See Also:
Constant Field Values

ATTR_UPDATE_LEVEL

static final String ATTR_UPDATE_LEVEL
See Also:
Constant Field Values
Method Detail

joinRoom

String joinRoom(String roomID,
                String password)
                throws RoomNotFoundException
Attempts to have client join a room.

Parameters:
roomID - - the id of the room to join
password - - the password for the room (only used if the room requires a password)
Returns:
Status.SUCCESS - the client joined the room
Throws:
RoomNotFoundException

leaveRoom

String leaveRoom(String roomID)
                 throws RoomNotFoundException
Removes the client from a room.

Parameters:
roomID - - the id of the room to leave
Returns:
Status.SUCCESS - the client left the room
Throws:
RoomNotFoundException

observeRoom

String observeRoom(String roomID,
                   String password)
                   throws RoomNotFoundException
Attempts to have the client observe a room.

Parameters:
roomID - - the roomID to observe
password - - the password for the room (only used if the room requires a password)
Returns:
Status.SUCCESS - the client is observing the room
Throws:
RoomNotFoundException

stopObservingRoom

String stopObservingRoom(String roomID)
                         throws RoomNotFoundException
Stop observing a room.

Parameters:
roomID - - the roomID to stop observing
Returns:
Status.SUCCESS - the client is no longer observing the room
Throws:
RoomNotFoundException

sendMessage

void sendMessage(String message,
                 String... args)
This generates a u7 which is sent to the client. It is similar to when a u2 is sent by a client.

Parameters:
message - - the name of the message
args - - the args to be sent with the message

getClientID

String getClientID()
Get the ID for the client. The ID is a unique integer assigned when the client is created.

Returns:
the unique id of the client

getUserID

String getUserID()
This is a convenience method for retrieving the userID of the client without having to do null check on the client. If the client is logged in it is the equivalent of getAccount().getUserID(). If the client is not logged in it returns the empty String "".

Returns:

getAccount

Account getAccount()
Get the Account for the client. This is the Account the client has used to login to the server. If the client is not logged in this returns null.

Returns:
the Account for the client if logged in, null otherwise

shutdown

void shutdown()
Removes the client from the server after sending any messages currently queued to be sent. This method is equivalent to shutdown(true).


shutdown

void shutdown(boolean sendRemainingMessages)
Removes the client from the server.

Parameters:
sendRemainingMessages - - if true no new messages will be allowed but any messages currently queued will be sent. If false, the client will shutdown immediately and any messages not yet sent will be lost.

getRoomList

Set<String> getRoomList()
Returns the room ID's of Rooms the Client is in.

Returns:
set of room ID's

getUID

String getUID()
Deprecated. use getAttribute

Returns the unique ID (determined by the Connection type) for this client. For example, in the case of a Socket connection the UID is the Connection's IP.


login

String login(String userID,
             String password)
Login the client to the server.

Parameters:
userID - the userID of the client
password - the password of the client
Returns:
Status.SUCCESS - the client has logged in

logoff

String logoff(String userID,
              String password)
Logoff the client from the server.

Parameters:
userID - the userID of the client
password - the password of the client
Returns:
Status.SUCCESS - the client has logged in

isLoggedIn

boolean isLoggedIn()
Returns true if the client has logged in.

Returns:
true if the client has logged in

getLastActive

long getLastActive()
Returns the System time (System.timeCurrentMillis()) the client was last active (i.e. the last time the Client sent data to the server).

Returns:
the System time the client was last active

getConnectToServerTime

long getConnectToServerTime()
Deprecated. use getAttribute

Retrieves the System time (System.timeCurrentMillis()) the client connected to the server.

Returns:
the System time the client connected to the server

setUpdateLevels

void setUpdateLevels(String roomID,
                     int levels)
Sets the update levels for the room. Update levels determine what information a client receives from a Room. For example, to receive room messages and the occupant count for a room "chessRoom": client.setUpdateLevels("chessRoom", UpdateLevel.ROOM_MESSAGES | UpdateLevel.OCCUPANT_COUNT);

Parameters:
roomID - the room the levels are set for
levels - the levels to set
See Also:
UpdateLevel

getUpdateLevels

Integer getUpdateLevels(String roomID)
Return the update levels for set for the given roomID. Return null if no update levels are set.

Parameters:
roomID - the room we want the update levels for

isShutdown

boolean isShutdown()
Returns true if shutdown has been called on the client.

Returns:
true if shutdown has been called on the client


Copyright USER1 Subsystems Corporation