|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectca.ualberta.cs.poker.free.client.PokerClient
public class PokerClient
Root for all example Java implementations of the client interface. Basic functionality: sends a version statement, receives state messages and remembers them, can send replies (actions), and exits on an ENDGAME message from the server. The function to overload is handleStateChange(). sendRaise(), sendCall(), and sendFold() can be used to send actions to the server. currentGameStateString has the most recent state information.
Field Summary | |
---|---|
java.lang.String |
currentGameStateString
This is the current game state. |
Constructor Summary | |
---|---|
PokerClient()
Creates a new instance of PokerClient. |
Method Summary | |
---|---|
void |
close()
Close the connection. |
void |
connect(java.net.InetAddress iaddr,
int port)
Connects to the server at the given IP address and port number. |
java.lang.String |
getClientID()
Returns the IP address and port number of the client. |
void |
handleStateChange()
Override to handle a state change. |
boolean |
isComplete(java.lang.String result)
Test if the message is complete (contains a terminal character) |
java.lang.String |
receiveMessage()
Receive a message from the server. |
void |
run()
Start the client. |
void |
sendAction(char action)
Send an action (action should be r, c, or f). |
void |
sendCall()
send a call action. |
void |
sendFold()
send a fold action. |
void |
sendMessage(java.lang.String message)
Send a message to the server. |
void |
sendRaise()
send a raise action. |
void |
setVerbose(boolean verbose)
Sets the verbose flag (if true, prints messages sent and received to stdout). |
void |
showVerbose(java.lang.String message)
Print a message to stdout if verbose==true. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.lang.String currentGameStateString
Constructor Detail |
---|
public PokerClient()
Method Detail |
---|
public void setVerbose(boolean verbose)
public java.lang.String getClientID()
public void showVerbose(java.lang.String message)
public void handleStateChange() throws java.io.IOException, java.net.SocketException
java.io.IOException
java.net.SocketException
public void connect(java.net.InetAddress iaddr, int port) throws java.io.IOException, java.net.SocketException
java.io.IOException
java.net.SocketException
public void sendAction(char action) throws java.io.IOException, java.net.SocketException
java.io.IOException
java.net.SocketException
public void sendRaise() throws java.io.IOException, java.net.SocketException
java.io.IOException
java.net.SocketException
public void sendCall() throws java.io.IOException, java.net.SocketException
java.io.IOException
java.net.SocketException
public void sendFold() throws java.io.IOException, java.net.SocketException
java.io.IOException
java.net.SocketException
public void run()
run
in interface java.lang.Runnable
public void close() throws java.io.IOException
java.io.IOException
public java.lang.String receiveMessage() throws java.net.SocketException, java.io.IOException
java.net.SocketException
java.io.IOException
public boolean isComplete(java.lang.String result)
public void sendMessage(java.lang.String message) throws java.net.SocketException, java.io.IOException
java.net.SocketException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |