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 java.lang.String ATTR_CONNECTIONTYPE
           
static java.lang.String ATTR_CONNECTTIME
           
static java.lang.String ATTR_GATEWAYID
           
static java.lang.String ATTR_GATEWAYTYPE
           
static java.lang.String ATTR_IP
           
static java.lang.String ATTR_LASTACTIVE
           
static java.lang.String ATTR_ROLES
           
static java.lang.String ATTR_TYPE
           
static java.lang.String ATTR_UPC_VERSION
           
static java.lang.String ATTR_UPDATE_LEVEL
           
static java.lang.String ATTR_USERAGENT
           
 
Method Summary
 Account getAccount()
          Get the Account for the client.
 java.lang.String getAddress()
          Returns the address (determined by the Connection type) for this client.
 java.lang.String getClientID()
          Get the ID for the client.
 long getConnectToServerTime()
          Deprecated. use getAttribute
 long getLastHeartbeatActive()
          Returns the System time (System.timeCurrentMillis()) the client was last active (i.e.
 java.util.Set<java.lang.String> getRoomList()
          Returns the room ID's of Rooms the Client is in.
 java.lang.Integer getUpdateLevels(java.lang.String roomID)
          Return the update levels for set for the given roomID.
 java.lang.String getUserID()
          This is a convenience method for retrieving the userID of the client without having to do null check on the client.
 boolean isAdmin()
          Returns true if the client is an administrator.
 boolean isLoggedIn()
          Returns true if the client has logged in.
 boolean isShutdown()
          Returns true if shutdown has been called on the client.
 java.lang.String joinRoom(java.lang.String roomID, java.lang.String password)
          Attempts to have client join a room.
 java.lang.String leaveRoom(java.lang.String roomID)
          Removes the client from a room.
 java.lang.String login(java.lang.String userID, java.lang.String password)
          Login the client to the server.
 java.lang.String logoff(java.lang.String password)
          Logoff the client from the server.
 java.lang.String observeRoom(java.lang.String roomID, java.lang.String password)
          Attempts to have the client observe a room.
 void sendMessage(java.lang.String message, java.lang.String... args)
          This generates a u7 which is sent to the client.
 void setUpdateLevels(java.lang.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.
 java.lang.String stopObservingRoom(java.lang.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, dispatchEvent, getEventClassMap, removeEventListener
 

Field Detail

ATTR_CONNECTTIME

static final java.lang.String ATTR_CONNECTTIME
See Also:
Constant Field Values

ATTR_GATEWAYID

static final java.lang.String ATTR_GATEWAYID
See Also:
Constant Field Values

ATTR_GATEWAYTYPE

static final java.lang.String ATTR_GATEWAYTYPE
See Also:
Constant Field Values

ATTR_CONNECTIONTYPE

static final java.lang.String ATTR_CONNECTIONTYPE
See Also:
Constant Field Values

ATTR_TYPE

static final java.lang.String ATTR_TYPE
See Also:
Constant Field Values

ATTR_USERAGENT

static final java.lang.String ATTR_USERAGENT
See Also:
Constant Field Values

ATTR_UPC_VERSION

static final java.lang.String ATTR_UPC_VERSION
See Also:
Constant Field Values

ATTR_IP

static final java.lang.String ATTR_IP
See Also:
Constant Field Values

ATTR_LASTACTIVE

static final java.lang.String ATTR_LASTACTIVE
See Also:
Constant Field Values

ATTR_UPDATE_LEVEL

static final java.lang.String ATTR_UPDATE_LEVEL
See Also:
Constant Field Values

ATTR_ROLES

static final java.lang.String ATTR_ROLES
See Also:
Constant Field Values
Method Detail

joinRoom

java.lang.String joinRoom(java.lang.String roomID,
                          java.lang.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

java.lang.String leaveRoom(java.lang.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

java.lang.String observeRoom(java.lang.String roomID,
                             java.lang.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

java.lang.String stopObservingRoom(java.lang.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(java.lang.String message,
                 java.lang.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

java.lang.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

java.lang.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. Note: Unlike Server.getAccount() you MUST NOT call dispose when finished working with an Account retrieved using this method.

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

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

Returns:
set of room ID's

getAddress

java.lang.String getAddress()
Returns the address (determined by the Connection type) for this client. For example, in the case of a socket connection the address is the remote IP.


login

java.lang.String login(java.lang.String userID,
                       java.lang.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

java.lang.String logoff(java.lang.String password)
Logoff the client from the server.

Parameters:
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

isAdmin

boolean isAdmin()
Returns true if the client is an administrator. Clients connected to the admin gateway are considered administrators.

Returns:
true if the client is an administrator

getLastHeartbeatActive

long getLastHeartbeatActive()
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(java.lang.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

java.lang.Integer getUpdateLevels(java.lang.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 - Tue Jan 28 2014, 05:05 PM -0500