|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectglassfrog.players.Player
glassfrog.players.SocketPlayer
public class SocketPlayer
The SocketPlayer class allows for players to connect to the game via socket. A Socket must be passed in to the constructor, which then sets up the PrintWriter and BufferedReader from which the actions are sent and recieved from agents
Field Summary | |
---|---|
protected java.io.BufferedReader |
br
The buffered reader for the socket. |
protected java.io.PrintWriter |
pw
The print writer for the socket |
protected java.net.Socket |
socket
The socket returned after a successfull connection |
protected java.net.ServerSocket |
ss
The server socket on which the player is to connect |
private int |
TIMEOUT
|
Constructor Summary | |
---|---|
SocketPlayer()
Empty default contructor for extendability |
|
SocketPlayer(java.lang.String name,
int buyIn,
java.io.BufferedReader br,
java.io.PrintWriter pw)
A contructror for SocketPlayer that takes a @BufferedReader and a @PrintWriter and established the player based on the pre-establised in and out. |
|
SocketPlayer(java.lang.String name,
int buyIn,
int port)
A contructor for Socket Player that takes a name, buyIn, a seat request and a port for connection |
|
SocketPlayer(java.lang.String name,
int buyIn,
java.net.Socket socket)
The SocketPlayer constructor that takes a port and opens a socket connection to handle action requests and updates to the player over a socket |
Method Summary | |
---|---|
java.lang.String |
getAction()
Gets the action of the player through the BufferedReader |
int |
getPort()
Returns the port the agent is connected to the player on |
java.net.Socket |
getSocket()
Return the @Socket the player is using |
private void |
initPlayer()
Set up the Players reader and writer. |
void |
initTimeout()
Used to set the player timeout to 60s per hand |
boolean |
isSocketPlayer()
Overrides the @Player implementation of isSocketPlayer and returns True |
void |
reconnect(java.net.Socket s)
The reconnect method allows for a player to be reconnected on @Dealer load |
void |
shutdown()
Closes down all sockets and I/O on shutdown |
void |
update(java.lang.String gamestate)
Send the gamestate to the player through the PrintWriter |
Methods inherited from class glassfrog.players.Player |
---|
addToScore, bet, call, compareTo, fold, getBuyIn, getCardString, getCurrentBet, getHandRank, getHandString, getName, getPosition, getScore, getSeat, getStack, getTotalCommitedToPot, initTimeout, isAAAIPlayer, isActed, isAllIn, isFolded, isGuiPlayer, payout, postBlind, resetHand, resetPlayer, resetRound, resetStack, setBuyIn, setCardString, setHandRank, setHandString, setName, setPosition, setScore, setSeat, setStack, subtractTotalCommitedToPot, toShortString, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected transient java.net.ServerSocket ss
protected transient java.net.Socket socket
protected transient java.io.BufferedReader br
protected transient java.io.PrintWriter pw
private final transient int TIMEOUT
Constructor Detail |
---|
public SocketPlayer()
public SocketPlayer(java.lang.String name, int buyIn, int port)
name
- a @String representing the name of the playerbuyIn
- an int representing the requested buyIn amountport
- an int representing a port to establish a connection onpublic SocketPlayer(java.lang.String name, int buyIn, java.net.Socket socket) throws java.io.IOException
name
- A string representing the player's namebuyIn
- an int representing the player's buyInsocket
- a socket to which the player is connected to an agent
java.io.IOException
public SocketPlayer(java.lang.String name, int buyIn, java.io.BufferedReader br, java.io.PrintWriter pw) throws java.io.IOException
name
- a @String representing the name of the playerbuyIn
- an int representing the requested buyIn amountbr
- A @BufferedReader the player will recieve gamestate information onpw
- A @APrintWriter the player will print action to
java.io.IOException
Method Detail |
---|
public int getPort()
public java.lang.String getAction()
getAction
in class Player
public void update(java.lang.String gamestate)
update
in class Player
gamestate
- The gamestate to sendprivate void initPlayer() throws java.io.IOException
java.io.IOException
public boolean isSocketPlayer()
isSocketPlayer
in class Player
public void reconnect(java.net.Socket s) throws java.io.IOException
s
- The @Socket for the player to be reconnected on
java.io.IOException
public java.net.Socket getSocket()
public void shutdown()
shutdown
in class Player
public void initTimeout()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |