Class prominence.msg.GenericHandler
All Packages Class Hierarchy This Package Previous Next Index
Class prominence.msg.GenericHandler
java.lang.Object
|
+----java.lang.Thread
|
+----prominence.msg.GenericHandler
- public class GenericHandler
- extends Thread
The client handler for a generic message streams-based server.
Accepts the client name from the GenericClient and attempts
to register in the server routing table. If successful, then routes
messages to other clients in the routing table.
- See Also:
- GenericServer
-
i
- The InputStream from the client.
-
myself
- Reference to a MessageOutput for this client.
-
name
- The client name.
-
o
- The OutputStream to the client.
-
routes
- The server routing table.
-
GenericHandler(Hashtable, InputStream, OutputStream)
- Creates a new GenericHandler with a specified routing
table and communication channel to the client.
-
accept(String)
- Attempts to register the client in the server routing table
and informs the client of success.
-
broadcast(byte[])
- Broadcasts a message body to all clients in the server routing
table except the sender.
-
execute(Queue)
- Starts a GenericMessageCopier that transfers messages
from the client's outbound queue to the client, and then proceeds
to route incoming messages from the client.
-
multicast(String[], byte[])
- Multicasts a message body to the specified list of clients.
-
route()
- Routes incoming messages from the client.
-
run()
- Reads the client name, attempts to register in the server routing
table, and if successful, proceeds to route messages to and from the
client.
-
send(byte[], MessageOutput)
- Sends a message body to a specified MessageOutput.
routes
protected Hashtable routes
- The server routing table.
i
protected InputStream i
- The InputStream from the client.
o
protected OutputStream o
- The OutputStream to the client.
name
protected String name
- The client name.
myself
protected MessageOutput myself
- Reference to a MessageOutput for this client.
GenericHandler
public GenericHandler(Hashtable routes,
InputStream i,
OutputStream o)
- Creates a new GenericHandler with a specified routing
table and communication channel to the client.
- Parameters:
- routes - The server routing table
- i - An InputStream from the client
- o - An OutputStream to the client
run
public void run()
- Reads the client name, attempts to register in the server routing
table, and if successful, proceeds to route messages to and from the
client.
This method is called by a new method when the superclass
start() method is called.
- Overrides:
- run in class Thread
- See Also:
- accept, start
accept
protected void accept(String name) throws IOException
- Attempts to register the client in the server routing table
and informs the client of success. If registered, proceeds to
route messages to and from the client.
Registers a QueueOutputStream in the routing table
that writes messages for the client into the client's outbound
message queue.
- Parameters:
- name - The client name
- Throws: IOException
- Occurs if a problem is encountered communicating
with the client.
- See Also:
- execute
execute
protected void execute(Queue q) throws IOException
- Starts a GenericMessageCopier that transfers messages
from the client's outbound queue to the client, and then proceeds
to route incoming messages from the client.
- Parameters:
- q - The client's outbound message queue
- Throws: IOException
- Occurs if a problem is encountered communicating
with the client.
- See Also:
- GenericMessageCopier, route
route
protected void route() throws IOException
- Routes incoming messages from the client.
Removes the routing header attached by the sender from each message,
and routes the message body into the appropriate outbound message
queues.
- Throws: IOException
- Occurs if a problem is encountered reading
from the client.
- See Also:
- broadcast, GenericHandler@multicast
broadcast
protected void broadcast(byte buffer[]) throws IOException
- Broadcasts a message body to all clients in the server routing
table except the sender.
- Parameters:
- buffer - The message body to be broadcast
- Throws: IOException
- Should not occur.
- See Also:
- send
multicast
protected void multicast(String dst[],
byte buffer[]) throws IOException
- Multicasts a message body to the specified list of clients.
- Parameters:
- dst - An array of target client names
- buffer - The message body to be multicast
- Throws: IOException
- Should not occur.
- See Also:
- send
send
protected void send(byte buffer[],
MessageOutput o) throws IOException
- Sends a message body to a specified MessageOutput.
Does not send a message back to the sender or to null.
- Throws: IOException
- Should not occur; we are writing to a Queue.
All Packages Class Hierarchy This Package Previous Next Index