Class TalkServer

java.lang.Object
   |
   +----TalkServer

public class TalkServer
extends Object
TalkServer - Server class for the NetTalk application. This class supports a TCP/IP based server that uses the Java client/server socket paradigm to communicate with a number of clients.

Author:
Jayme Manning, Paul Kronenwetter

Variable Index

 o index
 o VERSION

Constructor Index

 o TalkServer(int)
TalkServer - Constructor for the server portion of the NetTalk application.

Method Index

 o main(String[])
main - Method used to start the server itself from the command line.
 o processMessage(String, String)
processMessage - Method used to distribute messages amongst our clients.
 o registerClient(TalkServer. ClientThread)
registerClient - Method used to register our ClientThread within our storage Vector.
 o removeClient(int)
removeClient - Method used to remove a client from our active list.
 o sendAll(String)
sendAll - Method that is used to propagate a command message to all connected clients.
 o sendAll(String, String)
sendAll - Method that is used to propagate an user message to all connected clients.
 o sendSpecific(String, String)
sendSpecific - Method used to send a message to an individual user.
 o sendSpecificCommand(String, String)
sendSpecificCommand - Method used to send a command message to an individual user.
 o updateUserList(String)
updateUserList - Method used to send the given user a complete update of the list of connected users.

Variables

 o index
 public static int index
 o VERSION
 public static final double VERSION

Constructors

 o TalkServer
 public TalkServer(int tmpPort)
TalkServer - Constructor for the server portion of the NetTalk application.

Parameters:
tmpPort - Integer representing the port that the server is starting up on.

Methods

 o registerClient
 public void registerClient(TalkServer. ClientThread newClient)
registerClient - Method used to register our ClientThread within our storage Vector. Registered clients will receive appropriate message that deal with application control, etc...

Parameters:
newClient - ClientThread to register for operations.
 o removeClient
 public void removeClient(int remIndex)
removeClient - Method used to remove a client from our active list. This method should be called either when a client disconnects intentionally, or the connection is somehow broken.

Parameters:
remIndex - - The index of the client to remove.
 o processMessage
 public void processMessage(String message,
                            String from)
processMessage - Method used to distribute messages amongst our clients. This method takes a single parameter (the message string), and parses any control comments from the string before actually distributing it to the appropriate clients.

Parameters:
message - The String that was read from a client that needs to be distributed.
 o sendAll
 public void sendAll(String message)
sendAll - Method that is used to propagate a command message to all connected clients.

Parameters:
message - The String that is to be sent to all clients.
 o sendAll
 public void sendAll(String message,
                     String from)
sendAll - Method that is used to propagate an user message to all connected clients.

Parameters:
message - The String that is to be sent to all clients.
from - The user that originated the message.
 o sendSpecific
 public void sendSpecific(String message,
                          String from)
sendSpecific - Method used to send a message to an individual user. This method will parse the destination from the String. Because this message is to be parsed to glean the user name to send to, this method is used only with the MESSAGETO: token.

Parameters:
message - The message to be parsed and sent.
from - The originator of the message.
 o sendSpecificCommand
 public void sendSpecificCommand(String message,
                                 String user)
sendSpecificCommand - Method used to send a command message to an individual user.

Parameters:
message - The command message.
user - The user to send the message to.
 o updateUserList
 public void updateUserList(String userName)
updateUserList - Method used to send the given user a complete update of the list of connected users.

Parameters:
userName - The user that we send the update list.
 o main
 public static void main(String args[])
main - Method used to start the server itself from the command line. There should be only one command line option.

Parameters:
args[0] - This should be an integer representing a port number that the server will start up on.