ca.ualberta.cs.poker.free.server
Class PlayerAgent

java.lang.Object
  extended by ca.ualberta.cs.poker.free.server.PlayerAgent

public class PlayerAgent
extends java.lang.Object


Field Summary
 long elapsedSendingTime
          The total (match) elapsed sending time.
static java.lang.String messageTerminator
          The current message terminator is CR LF (13 10).
 
Constructor Summary
PlayerAgent(java.net.Socket socket, int playerIndex)
          Creates a new instance of PlayerAgent
 
Method Summary
 void close()
          Close the connection to the client.
 void incrementBankroll(double d)
          Increment the bankroll by d.
 boolean isComplete(java.lang.String result)
          A message is complete if it ends with the message terminator.
 java.lang.String receiveMessage()
          Receives a message from the client.
 void sendMessage(java.lang.String message)
          Send a message to the client.
 void setTimeRemaining(long timeRemaining)
          Reset the time at the beginning of the hand.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

messageTerminator

public static final java.lang.String messageTerminator
The current message terminator is CR LF (13 10).

See Also:
Constant Field Values

elapsedSendingTime

public long elapsedSendingTime
The total (match) elapsed sending time.

Constructor Detail

PlayerAgent

public PlayerAgent(java.net.Socket socket,
                   int playerIndex)
            throws java.net.SocketException,
                   java.io.IOException
Creates a new instance of PlayerAgent

Throws:
java.net.SocketException
java.io.IOException
Method Detail

setTimeRemaining

public void setTimeRemaining(long timeRemaining)
Reset the time at the beginning of the hand.


sendMessage

public void sendMessage(java.lang.String message)
                 throws TimeoutException
Send a message to the client. Appends a message terminator.

Throws:
TimeoutException

receiveMessage

public java.lang.String receiveMessage()
                                throws TimeoutException
Receives a message from the client. Removes the message terminator.

Throws:
TimeoutException

isComplete

public boolean isComplete(java.lang.String result)
A message is complete if it ends with the message terminator.


close

public void close()
           throws java.io.IOException
Close the connection to the client.

Throws:
java.io.IOException

incrementBankroll

public void incrementBankroll(double d)
Increment the bankroll by d.