|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbluegammon.io.BackgammonHandshake
A handshake consists of sending and receiving data as specified
below, where one player has server role and the other has client role.
Stores needed data for further setup, and initializes static aspects
of the game (rules and random seed).
SERVER CLIENT SEND random seed (int) SEND client id (int) SEND client name (UTF) SEND has saved game (boolean) IF saved game: SEND saved data (byte[]) SEND server id (int) SEND server name (UTF) SEND client color (boolean) IF no saved game: SEND rules(int) IF no remote saved game: SEND has saved game (boolean) IF no remote saved game AND has saved game: SEND saved data (byte[])
Constructor Summary | |
BackgammonHandshake()
|
Method Summary | |
void |
clientHandshake(java.io.DataInputStream dis,
java.io.DataOutputStream dos,
java.lang.String localName)
Performs a handshake as a client. |
int |
getRemoteId()
Returns the id of the other device after a successful handshake. |
char[] |
getRemoteName()
Returns the name of the other device after a successful handshake. |
byte[] |
getSavedGame()
Returns the data of a shared saved game. |
boolean |
isRemoteResume()
Returns whether the saved game data was collected from the remote device or from this device. |
boolean |
isWhite()
Returns the color of this device as decided by the handshake. |
void |
serverHandshake(java.io.DataInputStream dis,
java.io.DataOutputStream dos,
java.lang.String localName)
Performs a handshake as a server. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public BackgammonHandshake()
Method Detail |
public void serverHandshake(java.io.DataInputStream dis, java.io.DataOutputStream dos, java.lang.String localName) throws java.io.IOException
dis
- The input stream from the other device.dos
- The output stream to the other device.localName
- The name of this device.
java.io.IOException
- if the handshake fails.public void clientHandshake(java.io.DataInputStream dis, java.io.DataOutputStream dos, java.lang.String localName) throws java.io.IOException
dis
- The input stream from the other device.dos
- The output stream to the other device.localName
- The name of this device.
java.io.IOException
- if the handshake fails.public int getRemoteId()
public char[] getRemoteName()
public byte[] getSavedGame()
public boolean isWhite()
public boolean isRemoteResume()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |