|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectPlayer
NetworkPlayer
public class NetworkPlayer
This class inerits from player. It is involved in the network game. This identifies that a network player is the second player.
Field Summary |
---|
Fields inherited from class Player |
---|
LOCALPLAYER |
Constructor Summary | |
---|---|
NetworkPlayer(int playerNum,
Rules rules,
Driver theDriver)
Constructor that creates a default object of this class |
Method Summary | |
---|---|
void |
acceptDraw(Player player)
When the current player accepts a draw, this method is called in the opposite player to inform them that the draw has been accepted. |
void |
cleanup()
Closes the streams & sockets |
void |
connectToHost()
This method establishes a connection to the host |
void |
endInDeclineDraw(Player player)
Method is invoked if the other player declines a draw. |
void |
endInDraw(Player player)
Method that is invoked when the end of game conditions have been met. |
void |
endOfGame(java.lang.String endMessage)
Method that is invoked when the end of game conditions have been met. |
int |
getPlayerType()
Return the integer constant representing the networkPlayer class |
void |
offerDraw(Player player)
A DRAWOFFER message is sent to the remote player. |
java.lang.Integer |
processCommand(int command)
Process an incoming command, and take the appropriate action. |
void |
sendColor()
This method sends the color of this player to the other computer; will only be executed by the host computer. |
void |
sendCommand(int type)
This method sends some command over network to the local system |
void |
sendMove()
The move is sent to the remote player |
void |
sendName()
This method sends the name of this player to the other computer |
void |
setHost(java.net.URL host)
Set the host that we'll connect to if we're a remote system |
void |
takeColor()
This method gets the color of this player from the other computer; this method will only be executed by the client computer. |
void |
takeName()
This method takes the name of the other player and stores it |
void |
waitForConnect()
The host waits for the network player to connect. |
void |
waitForPlayer()
Wait for the other player to send us a move or command. |
Methods inherited from class Player |
---|
getColor, getName, getNumber, getType, makeMove, setColor, setName, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public NetworkPlayer(int playerNum, Rules rules, Driver theDriver)
Method Detail |
---|
public void setHost(java.net.URL host)
public void waitForConnect()
public void connectToHost()
host
- - the host to connect topublic void takeName()
public void sendName()
public void takeColor()
public void sendColor()
public void waitForPlayer()
public java.lang.Integer processCommand(int command)
public void sendCommand(int type)
type
- - the type of command that is an integer valuepublic void sendMove()
move
- - move that was made by the local playerpublic void offerDraw(Player player)
offerDraw
in class Player
public void acceptDraw(Player player)
acceptDraw
in class Player
public void endOfGame(java.lang.String endMessage)
endOfGame
in class Player
endMessage
- Message indicating the end of the game.public int getPlayerType()
public void cleanup()
public void endInDeclineDraw(Player player)
Player
endInDeclineDraw
in class Player
public void endInDraw(Player player)
Player
endInDraw
in class Player
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |