Class Client

java.lang.Object
  extended by Client
All Implemented Interfaces:
java.lang.Runnable

public class Client
extends java.lang.Object
implements java.lang.Runnable

Holds personal information needs to communicate with a given client.


Field Summary
static char LINE_RETURN
           
 
Constructor Summary
Client(java.net.Socket connection)
          initializes an output stream to the client
 
Method Summary
 java.lang.String getUserName()
          Gets the user name of the client
 void run()
          Overrided run method that listens for incoming messages from the client.
 boolean sendMsg(java.lang.String message)
          Sends a message to a client
 void setRoom(Room room)
           
 void setUserName(java.lang.String userName)
          Sets the user name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LINE_RETURN

public static final char LINE_RETURN
See Also:
Constant Field Values
Constructor Detail

Client

public Client(java.net.Socket connection)
initializes an output stream to the client

Parameters:
connection - A socket to for the client
Method Detail

sendMsg

public boolean sendMsg(java.lang.String message)
Sends a message to a client

Parameters:
message - The message that is to be sent
Returns:
true if the message was sent succesfully, false if it fails

getUserName

public java.lang.String getUserName()
Gets the user name of the client

Returns:
the clients user name

setUserName

public void setUserName(java.lang.String userName)
Sets the user name

Parameters:
userName - Sets the user name to the given name

run

public void run()
Overrided run method that listens for incoming messages from the client. Runs when this thread is started.

Specified by:
run in interface java.lang.Runnable

setRoom

public void setRoom(Room room)