|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--PaP.Actor | +--PaP.ApplicationActor | +--Chat.v1_1.ChatServer
A ChatServer is an Actor that lets one or more ChatClients connect to and
disconnect from it. When a ChatClient wants to send a message to all the
other connected ChatClients, it sends the message to the ChatServer which
then distributes it to all the other ChatClients.
A ChatClient connects to a ChatServer by sending a RoleFigurePlugIn request
to the Director. He then creates a RoleSession between the ChatClient and
the specified ChatServer. Once a RoleSession is created the ChatClient can
send ApplicationMessages of one of the predefined types to the ChatServer.
Field Summary | |
private java.lang.String |
CHAT_MESSAGE
Used when a ChatClient wants to send a message to the ChatServer. |
private java.lang.String |
CONNECT_USER
Used when a ChatClient wants to connect to a ChatServer. |
private java.lang.String |
DISCONNECT_USER
Used when a ChatClient wants to disconnect from a ChatServer. |
private java.lang.String |
GET_USERLIST
Used when a ChatClient wants a list of all the ChatClients currently connected to the ChatServer. |
private java.util.Hashtable |
ht
Hashtable where all the ChatClient's GAI are stored with their username as keys. |
private boolean |
initiated
Indicates wether initial ActorPlugIn has been performed or not |
Fields inherited from class PaP.Actor |
bf, context, fh |
Constructor Summary | |
ChatServer()
Creates a new ChatServer. |
Method Summary | |
RequestResult |
applicationActorEntry(RequestPars rpars)
This method is the common entry point for all external requests to this actor. |
private void |
connectUser(java.lang.String username,
RoleSession rs)
Adds the user with the specified username to the the hashtable of users connected to this ChatServer. |
private void |
dbg(java.lang.String dbg)
Sends debug information to this actor's BaseFrame window, which is an interactive debug client window for several entities. |
private void |
disconnectUser(java.lang.String username)
Removes the user with the specified username from the hashtable of users connected to this ChatServer. |
private void |
distributeMessage(java.lang.String fromUser,
java.lang.String message)
Sends the specified message to all connected ChatClients except the user with the specified username. |
private java.lang.String[] |
getConnectedUsers()
Returns a string array with a list of the usernames and the GAI of all the ChatClients currently connected to this ChatServer. |
private boolean |
isUserConnected(java.lang.String username)
Checks all the usernames of the users connected (all the keys in the hashtable) to see if the user with the specified username is connected. |
Methods inherited from class PaP.Actor |
findRoleSession, getGAI, start, status, term |
Methods inherited from class java.lang.Object |
|
Field Detail |
private final java.lang.String CHAT_MESSAGE
private final java.lang.String CONNECT_USER
private final java.lang.String DISCONNECT_USER
private final java.lang.String GET_USERLIST
private java.util.Hashtable ht
private boolean initiated
Constructor Detail |
public ChatServer()
Method Detail |
public RequestResult applicationActorEntry(RequestPars rpars) throws java.lang.Exception
applicationActorEntry
in class ApplicationActor
rpars
- Instance of RequestPars which specifies type of request and
additional parametres to the request.java.lang.Exception
- private void connectUser(java.lang.String username, RoleSession rs)
username
- The username of the user connecting.rs
- The rolesession the user is connected via.private void dbg(java.lang.String dbg)
dbg
in class ApplicationActor
dbg
- The debug information to be sent.private void disconnectUser(java.lang.String username)
username
- The username of the user disconnecting.private void distributeMessage(java.lang.String fromUser, java.lang.String message)
fromUser
- The username of the user sending the message.message
- The message to distribute.private java.lang.String[] getConnectedUsers()
private boolean isUserConnected(java.lang.String username)
username
- The username of the user to search for.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |