Class ChatRoomClient

java.lang.Object
  |
  +--ChatRoomClient

public class ChatRoomClient
extends java.lang.Object

A ChatRoomClient.


Field Summary
protected  ChatRoomProtocol protocol
           
 
Constructor Summary
ChatRoomClient()
          Constructs a new ChatRoomClient with the default values of IP and server port.
ChatRoomClient(java.lang.String IP, int port)
          Constructs a new ChatRoomClient with the default values of IP and server port.
 
Method Summary
 void connect()
           
 void disconnect()
          Disconnect from the server.
 void displayMessage(java.lang.String message)
          Update the UI by displaying the recieved message.
 java.lang.String getUserName()
          Returns the client's user name.
 boolean isConnected()
          Return true if the user connected to the server.
 void requestUserName()
          Requests a name from the user by opening a Dialog box.
 void sendMessage(java.lang.String message)
          Send a string message to the server.
 void setUI(ChatRoomClientGUI gui)
          Sets the UI of this ChatRoomClient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

protocol

protected ChatRoomProtocol protocol
Constructor Detail

ChatRoomClient

public ChatRoomClient()
Constructs a new ChatRoomClient with the default values of IP and server port. The defaults are: IP = 127.0.0.1, port = 9090.


ChatRoomClient

public ChatRoomClient(java.lang.String IP,
                      int port)
Constructs a new ChatRoomClient with the default values of IP and server port. The defaults are: IP = 127.0.0.1, port = 9090.

Method Detail

setUI

public void setUI(ChatRoomClientGUI gui)
Sets the UI of this ChatRoomClient


isConnected

public boolean isConnected()
Return true if the user connected to the server.

Returns:
true if the user connected to the server.

getUserName

public java.lang.String getUserName()
Returns the client's user name.

Returns:
the user name.

displayMessage

public void displayMessage(java.lang.String message)
Update the UI by displaying the recieved message.

Parameters:
message - The message to add.

requestUserName

public void requestUserName()
Requests a name from the user by opening a Dialog box.


disconnect

public void disconnect()
Disconnect from the server.


sendMessage

public void sendMessage(java.lang.String message)
Send a string message to the server.

Parameters:
message - the string message

connect

public void connect()