Class reader

 

java.lang.Object

   |

   +----java.lang.Thread

           |

           +----reader

class reader extends Thread

Constructors

reader - public reader(server s, int index)
Accepts the server and index parameters passed from the server thread. Binds these parameters to local variables to allow for use by other local functions.
Methods

run - public void run() Overrides: run in class Thread
The main class of the reader thread. This class first checks the user type and then forwards the appropriate startup information to that client. Other servers are sent the current list of users and what channel they are on. Clients are informed of other users on their channel, and the channel list. The update flag is set to check the server table. The run class then enters an infinite loop to read network input and handle requests from the client. When the user disconnects, a message is sent to other users removing the current user from the other lists. The functions called are determined by the start of the string received from the client. This string is passed to the appropriate function.

String starts with...	Function called.

TEXT&			text

GO&			gochannel

ADDCHANNEL&		addchannel

ADDUSER&		adduser

REMOVEUSER&		removeuser

FILTER&			filter

UNFILTER&		unfilter

STATUS&			status

text - void text(String input)
The text class forwards text messages to the correct recipients. Several requirements must be met to forward a text message. The message cannot be sent to the originating client of the message, the users must be on the same channel, remote users do not receive messages through this function, the user sending the message must not be filtered by the user receiving the message and servers receive all messages from other users and servers. If these conditions are met the message is sent to the appropriate client using write_net_output, defined in the server class.
gochannel - void gochannel(String input)
gochannel moves the client to another channel by updating the information in the table and informing other clients of the change in status. The update flag is also set, allowing the server to clear any empty channels that appear.
addchannel - void addchannel(String input)
addchannel is similar to gochannel, however a new channel is created first and then the client is moved to this new channel. The server table is updated and the update flag set.
filter - void filter(String input)
Adds the username to be filtered to this client's filtering string. The names in this string are separated by the | character.
unfilter - void unfilter(String input)
Searches the filter string and removes the username to be unfiltered. No action is taken if the username is not in the filter string.
status - void status(String input)
Sends the client requesting server status a series of text messages containing the current state of the server. The messages include the number of users connected, the number of other servers connected, the number of open connections, and the users current channel. The update flag is set to refresh the client's channel list.
adduser - void adduser(String input)
Accepts a request from another server to add a user to the server table. The user and user's channel are added to the local table. The other clients are notified of the change. The user is added as a remote user. Sets the update flag.
removeuser - void removeuser(String input)
Removes a remote user from the local table. Sets the update flag and informs other clients of the removal of the user.