edu.trinity.cs.bmassing.rmi
Class ChatClientImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by edu.trinity.cs.bmassing.rmi.ChatPartyImpl
                  extended by edu.trinity.cs.bmassing.rmi.ChatClientImpl
All Implemented Interfaces:
ChatClient, ChatParty, java.io.Serializable, java.rmi.Remote

public class ChatClientImpl
extends ChatPartyImpl
implements ChatClient

Class for client for simple chat program. An object of this class provides the functionality needed to communicate with the server and other clients; the user interface is provided by an object of a class implementing the ChatClientUI interface.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.trinity.cs.bmassing.rmi.ChatPartyImpl
clients, errorPrefix, serverPrefix
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
ChatClientImpl(java.lang.String name, java.lang.String serverHost, ChatClientUI ui)
          Constructs client object, querying server for a list of other clients and displaying this information.
 
Method Summary
 void addClient(ChatClient c)
          Adds client, displaying some info about the new client.
 void display(java.lang.String message)
          Displays message, using whatever method is provided by the user interface for the client.
 java.lang.String getAddress()
          Gets client's hostname/IPA.
 java.lang.String getMessagePrefix()
          Gets prefix for messages broadcast by this object.
 java.lang.String getScreenName()
          Gets client's screen name.
 void removeClient(ChatClient c)
          Removes client, displaying some info about it.
 void shutdown()
          Shuts down, notifying server that we're leaving.
 void startup()
          Starts up.
 
Methods inherited from class edu.trinity.cs.bmassing.rmi.ChatPartyImpl
broadcast
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.trinity.cs.bmassing.rmi.ChatParty
broadcast
 

Constructor Detail

ChatClientImpl

public ChatClientImpl(java.lang.String name,
                      java.lang.String serverHost,
                      ChatClientUI ui)
               throws java.rmi.RemoteException,
                      java.rmi.NotBoundException,
                      java.net.MalformedURLException
Constructs client object, querying server for a list of other clients and displaying this information.

Parameters:
name - screen name
serverHost - host where server is running
ui - user interface for client (provides something on which to display messages, etc.)
Throws:
java.rmi.RemoteException
java.rmi.NotBoundException
java.net.MalformedURLException
Method Detail

addClient

public void addClient(ChatClient c)
               throws java.rmi.RemoteException
Adds client, displaying some info about the new client.

Specified by:
addClient in interface ChatParty
Overrides:
addClient in class ChatPartyImpl
Parameters:
c - client to add
Throws:
java.rmi.RemoteException

removeClient

public void removeClient(ChatClient c)
                  throws java.rmi.RemoteException
Removes client, displaying some info about it.

Specified by:
removeClient in interface ChatParty
Overrides:
removeClient in class ChatPartyImpl
Parameters:
c - client to remove
Throws:
java.rmi.RemoteException

getScreenName

public java.lang.String getScreenName()
                               throws java.rmi.RemoteException
Gets client's screen name.

Specified by:
getScreenName in interface ChatClient
Returns:
screen name
Throws:
java.rmi.RemoteException

getAddress

public java.lang.String getAddress()
                            throws java.rmi.RemoteException
Gets client's hostname/IPA.

Specified by:
getAddress in interface ChatClient
Returns:
hostname and IPA, in string form
Throws:
java.rmi.RemoteException

display

public void display(java.lang.String message)
             throws java.rmi.RemoteException
Displays message, using whatever method is provided by the user interface for the client.

Specified by:
display in interface ChatParty
Parameters:
message - message to display
Throws:
java.rmi.RemoteException

startup

public void startup()
             throws java.rmi.RemoteException
Starts up.

Specified by:
startup in interface ChatClient
Throws:
java.rmi.RemoteException

shutdown

public void shutdown()
              throws java.rmi.RemoteException
Shuts down, notifying server that we're leaving.

Specified by:
shutdown in interface ChatClient
Throws:
java.rmi.RemoteException

getMessagePrefix

public java.lang.String getMessagePrefix()
Gets prefix for messages broadcast by this object.

Specified by:
getMessagePrefix in class ChatPartyImpl
Returns:
prefix for messages (screen name)