net.bluebones.boggle
Class Client

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by net.bluebones.boggle.Client
All Implemented Interfaces:
Serializable, Remote, IClient

public class Client
extends UnicastRemoteObject
implements IClient

Controls the network side of the application from the client side.

Version:
0.3 $Revision: 1.3 $
Author:
Thomas David Baker
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
Client(Player player, String name)
          Initialises a Client.
 
Method Summary
 String getAddr()
          Gets the RMI address of this Client.
 String getName()
          Gets the name of this client.
 boolean isActive(GameId gameId)
          Determines if this Client is actively connected to the specified game.
static void main(String[] args)
          Simple commandline test of Client.
 void problem(String msg)
          Displays an error message on this Client.
 void results(Round round, Rubber rubber)
          Notifies the client to process the results of a previous round.
 void setRubber(Rubber r)
          Sets the rubber information for this client.
 void startGame(char[][] letters, int timeInSecs, GameId gameId)
          Notifies the client to start a game with the specified letters.
 String toString()
          Gets a String representation of this Client.
 
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, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Client

public Client(Player player,
              String name)
       throws RemoteException,
              UnknownHostException
Initialises a Client.

Throws:
RemoteException - If anything goes wrong with the RMI.
UnknownHostException - If client is unable to determine its own address.
Method Detail

startGame

public void startGame(char[][] letters,
                      int timeInSecs,
                      GameId gameId)
               throws RemoteException
Notifies the client to start a game with the specified letters.

Specified by:
startGame in interface IClient
Parameters:
letters - Letters to initialise the board with.
timeInSecs - Time of game in seconds.
gameId - Universally unique identifier for this game.
Throws:
RemoteException - If anything goes wrong with the RMI.

results

public void results(Round round,
                    Rubber rubber)
             throws RemoteException
Notifies the client to process the results of a previous round.

Specified by:
results in interface IClient
Parameters:
round - Results to process.
rubber - Details of the rubber.
Throws:
RemoteException - If anything goes wrong with the RMI.

isActive

public boolean isActive(GameId gameId)
                 throws RemoteException
Determines if this Client is actively connected to the specified game.

Specified by:
isActive in interface IClient
Parameters:
gameId - GameID of game to check for participation in.
Returns:
Returns true if playing the game represented by gameId.
Throws:
RemoteException - If anything goes wrong with the RMI.

setRubber

public void setRubber(Rubber r)
               throws RemoteException
Sets the rubber information for this client.

Specified by:
setRubber in interface IClient
Parameters:
r - Rubber to set.
Throws:
RemoteException - If anything goes wrong with the RMI.

getAddr

public String getAddr()
Gets the RMI address of this Client.

Returns:
The RMI address of this Client.

problem

public void problem(String msg)
Displays an error message on this Client.

Parameters:
msg - Message to show.

getName

public String getName()
Gets the name of this client.

Returns:
String name of this client.

main

public static void main(String[] args)
                 throws UnknownHostException,
                        NotBoundException,
                        RemoteException,
                        MalformedURLException
Simple commandline test of Client.

Parameters:
args - Commandline arguments.
Throws:
UnknownHostException - If local IP cannot be detected.
NotBoundException - If server cannot be found.
RemoteException - If anything goes wrong with the RMI.
MalformedURLException - If RMI address is malformed.

toString

public String toString()
Gets a String representation of this Client.

Overrides:
toString in class RemoteObject
Returns:
String representation.