Class prominence.chat.ChatSystemHandler
All Packages Class Hierarchy This Package Previous Next Index
Class prominence.chat.ChatSystemHandler
java.lang.Object
|
+----java.lang.Thread
|
+----prominence.msg.GenericHandler
|
+----prominence.chat.ChatSystemHandler
- public class ChatSystemHandler
- extends GenericHandler
An extension to the GenericHandler class that supports
message source identification and a naming registry, i.e.,
each message is accompanied by the name of the sender, and the
server announces clients' joining and leaving.
- See Also:
- ChatSystemServer, GenericHandler
-
ChatSystemHandler(Hashtable, InputStream, OutputStream)
- Creates a new ChatSystemHandler with communications streams
and a routing table.
-
accept(String)
- Attempts to register the client in the routing table.
-
announce(boolean)
- Announces the client joining or leaving to all other users.
-
listUsers()
- Lists all current clients to the new client.
-
send(byte[], MessageOutput)
- Sends a message to the specified destination.
ChatSystemHandler
public ChatSystemHandler(Hashtable routes,
InputStream i,
OutputStream o)
- Creates a new ChatSystemHandler with communications streams
and a routing table.
- Parameters:
- routes - The global routing table
- i - An InputStream from the client
- o - An OutputStream to the client
accept
protected void accept(String name) throws IOException
- Attempts to register the client in the routing table. If successful,
calls the superclass execute() method to process incoming messages.
Lists the current clients to the new client, and announces the new
client joining and leaving to other clients.
- Parameters:
- name - The client name
- Throws: IOException
- Occurs if a problem arises with the communication
streams.
- Overrides:
- accept in class GenericHandler
- See Also:
- execute, announce, listUsers
announce
protected void announce(boolean isJoin) throws IOException
- Announces the client joining or leaving to all other users.
- Parameters:
- isJoin - Whether the client is joining or leaving.
- Throws: IOException
- Should not occur.
- See Also:
- Registry
listUsers
protected void listUsers() throws IOException
- Lists all current clients to the new client.
- Throws: IOException
- Should not occur.
- See Also:
- Registry
send
protected void send(byte buffer[],
MessageOutput o) throws IOException
- Sends a message to the specified destination. Does not send
a message to self, or if destination is null.
Attaches the client name to the message so the recipient can
identify the sender.
- Parameters:
- buffer - The message to be sent
- o - The destination MessageOutput
- Throws: IOException
- Occurs if there is a problem sending the message.
- Overrides:
- send in class GenericHandler
- See Also:
- demux
All Packages Class Hierarchy This Package Previous Next Index