vooga.network.chat
Class VoogaChatServer

java.lang.Object
  extended by java.lang.Thread
      extended by vooga.network.VoogaServer
          extended by vooga.network.chat.VoogaChatServer
All Implemented Interfaces:
java.lang.Runnable

public class VoogaChatServer
extends VoogaServer

VoogaChatServer maintains map of all open sockets and maintains set of connected users with more functionality to add/remove users and broadcast messages to chatrooms.

Author:
tgr3, tws10, sam1

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class vooga.network.VoogaServer
SERVER
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
VoogaChatServer()
           
 
Method Summary
 void addFriend(java.lang.String userName, java.lang.String friendString)
          Adds the users specified in friendString as friends to userName.
 void addUserToChannel(long channelID, java.lang.String userName)
          Adds client user to a channel
 void disconnectUser(java.lang.String userName)
           
 int getUserID(java.lang.String target)
          Get's client user's unique identifier
 void initialize()
          Allows subclasses to perform an additional initialization after the server has been constructed and started listening.
protected  void intializeConnection(java.lang.String clientName, java.net.Socket clientSocket)
          Allows server subclasses to implement additional initialization for a user connection, such as starting a server thread to receive input from that client.
static void main(java.lang.String[] args)
           
 void notify(java.lang.String updatingUser, java.lang.String status)
          Notifies all friends of updatingUser that updatingUser is changing status on FRIEND_UPDATE_CHANNEL.
 void notifyOfConnect(java.lang.String connectingUser)
           
 void notifyOfDisconnect(java.lang.String disconnectingUser)
           
 void removeUserFromChannel(long channelID, java.lang.String userName)
          Removes client user from a chatroom
 void sendToChannel(long channelID, java.lang.String sender, java.lang.String message)
          Sends message to a chatroom
 void sendToUser(java.lang.String receiver, java.lang.String sender, java.lang.String message, long channelID)
          Sends a personal message to the spcifeid user.
 
Methods inherited from class vooga.network.VoogaServer
getAllConnectedUsers, getInStream, getMySocket, getOutStream, listeningToSocket, removeConnection, run
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VoogaChatServer

public VoogaChatServer()
                throws java.io.IOException
Throws:
java.io.IOException
Method Detail

initialize

public void initialize()
Description copied from class: VoogaServer
Allows subclasses to perform an additional initialization after the server has been constructed and started listening.

Specified by:
initialize in class VoogaServer

addUserToChannel

public void addUserToChannel(long channelID,
                             java.lang.String userName)
Adds client user to a channel

Parameters:
channelID - unique room identifier
userName - to be added to unique room

getUserID

public int getUserID(java.lang.String target)
Get's client user's unique identifier

Parameters:
target -
Returns:
hashCode of client user's unique identifier

removeUserFromChannel

public void removeUserFromChannel(long channelID,
                                  java.lang.String userName)
Removes client user from a chatroom

Parameters:
channelID - unique room identifier
userName - to be removed to unique room

sendToChannel

public void sendToChannel(long channelID,
                          java.lang.String sender,
                          java.lang.String message)
Sends message to a chatroom

Parameters:
channelID - unique room identifier
sender - sender in the room
message - message to be sent

sendToUser

public void sendToUser(java.lang.String receiver,
                       java.lang.String sender,
                       java.lang.String message,
                       long channelID)
                throws VoogaNetworkException
Sends a personal message to the spcifeid user.

Parameters:
receiver - Intended receiver of the message.
sender - Sender of message.
message - Message Contents.
channelID - Channel the message should be sent to.
Throws:
VoogaNetworkException

intializeConnection

protected void intializeConnection(java.lang.String clientName,
                                   java.net.Socket clientSocket)
Description copied from class: VoogaServer
Allows server subclasses to implement additional initialization for a user connection, such as starting a server thread to receive input from that client.

Specified by:
intializeConnection in class VoogaServer

main

public static void main(java.lang.String[] args)

addFriend

public void addFriend(java.lang.String userName,
                      java.lang.String friendString)
Adds the users specified in friendString as friends to userName. Notifies on FRIEND_UPDATE_CHANNEL if the user is online.

Parameters:
userName -
friendString -

notifyOfDisconnect

public void notifyOfDisconnect(java.lang.String disconnectingUser)

disconnectUser

public void disconnectUser(java.lang.String userName)

notifyOfConnect

public void notifyOfConnect(java.lang.String connectingUser)

notify

public void notify(java.lang.String updatingUser,
                   java.lang.String status)
Notifies all friends of updatingUser that updatingUser is changing status on FRIEND_UPDATE_CHANNEL.

Parameters:
updatingUser -
status -