nu.dll.fia
Class Client

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--nu.dll.fia.Client
All Implemented Interfaces:
RemotePlayer, java.lang.Runnable

public class Client
extends java.lang.Thread
implements RemotePlayer

This is the class that servers for all communication between the Fia game and a Fia server. It takes care of connecting and reading data from the server, as well as issuing commands given to it by doCommand(String). It starts one thread to provide non-blocking I/O with the server.


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Client(java.lang.String nickName, java.lang.String host, int port, javax.swing.JTextArea textArea, FiaPanel panel)
           
 
Method Summary
 int dice(int max, int multip)
          Query the server to roll a dice and block until a response has been received.
 void didTurn(nu.dll.fia.Player p, nu.dll.fia.Move m, boolean wasImpossible)
          Called by GameEngine when a user has done their move.
 void doCommand(java.lang.String s)
          Performs a command issued by a user, such as JOIN or LIST.
 nu.dll.fia.RemoteMove doTurn(int playerIndex)
          Waits for a turn by a remote player.
 boolean isActive()
           
 void run()
          The thread's "main" method, which only reads the object data from the server.
 long time()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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

Client

public Client(java.lang.String nickName,
              java.lang.String host,
              int port,
              javax.swing.JTextArea textArea,
              FiaPanel panel)
Method Detail

run

public void run()
The thread's "main" method, which only reads the object data from the server. Upon receipt of a "command", a Message object is constructed using the received data and passed to the serverMessage(Message) method.
Overrides:
run in class java.lang.Thread

time

public long time()

dice

public int dice(int max,
                int multip)
Query the server to roll a dice and block until a response has been received.

isActive

public boolean isActive()

doTurn

public nu.dll.fia.RemoteMove doTurn(int playerIndex)
Waits for a turn by a remote player.
Specified by:
doTurn in interface RemotePlayer

didTurn

public void didTurn(nu.dll.fia.Player p,
                    nu.dll.fia.Move m,
                    boolean wasImpossible)
Called by GameEngine when a user has done their move.

doCommand

public void doCommand(java.lang.String s)
Performs a command issued by a user, such as JOIN or LIST.