|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectsoc.client.SOCDisplaylessPlayerClient
GUI-less standalone client for connecting to the SOCServer. If you want another connection port, you have to specify it as the "port" argument in the html source. If you run this as a stand-alone, you have to specify the port.
The SOCRobotClient is based on this client.
| Field Summary | |
protected java.util.Hashtable |
channels
the channels |
protected boolean |
connected
|
protected java.lang.String |
doc
|
protected java.lang.Exception |
ex
|
protected java.util.Hashtable |
games
the games |
protected boolean |
gotPassword
true if we've stored the password |
protected java.lang.String |
host
|
protected java.io.DataInputStream |
in
|
protected java.lang.String |
lastMessage
|
protected java.lang.String |
nickname
the nickname |
protected java.io.DataOutputStream |
out
|
protected java.lang.String |
password
the password |
protected int |
port
|
protected java.lang.Thread |
reader
|
protected boolean |
rejected
were we rejected from server? (full or robot name taken) |
protected java.net.Socket |
s
|
protected LocalStringConnection |
sLocal
|
protected int |
sLocalVersion
Server version number, sent soon after connect, or -1 if unknown |
protected static java.lang.String |
STATSPREFEX
|
protected java.lang.String |
strSocketName
|
protected int |
sVersion
Server version number, sent soon after connect, or -1 if unknown |
| Constructor Summary | |
SOCDisplaylessPlayerClient()
Create a SOCDisplaylessPlayerClient |
|
SOCDisplaylessPlayerClient(java.lang.String s,
boolean visual)
Constructor for connecting to a local game (practice) on a local stringport. |
|
SOCDisplaylessPlayerClient(java.lang.String h,
int p,
boolean visual)
Constructor for connecting to the specified host, on the specified port |
|
| Method Summary | |
void |
acceptOffer(SOCGame ga,
int from)
the user is accepting an offer |
void |
bankTrade(SOCGame ga,
SOCResourceSet give,
SOCResourceSet get)
the user wants to trade with the bank |
void |
buildRequest(SOCGame ga,
int piece)
request to build something |
void |
buyDevCard(SOCGame ga)
request to buy a development card |
void |
cancelBuildRequest(SOCGame ga,
int piece)
request to cancel building something |
void |
changeFace(SOCGame ga,
int id)
the user is changing the face image |
void |
choosePlayer(SOCGame ga,
int pn)
the user chose a player to steal from |
void |
chSend(java.lang.String ch,
java.lang.String mes)
send a text message to a channel |
void |
clearOffer(SOCGame ga)
the user is clearing an offer |
void |
destroy()
destroy the applet |
void |
discard(SOCGame ga,
SOCResourceSet rs)
the user wants to discard |
protected void |
disconnect()
disconnect from the net, and from any local practice server |
void |
discoveryPick(SOCGame ga,
SOCResourceSet rscs)
the user picked 2 resources to discover |
void |
endTurn(SOCGame ga)
the user is done with the turn |
java.lang.String |
getNickname()
|
protected void |
handleBCASTTEXTMSG(SOCBCastTextMsg mes)
handle a broadcast text message |
protected void |
handleBOARDLAYOUT(SOCBoardLayout mes)
handle the "board layout" message |
protected void |
handleCANCELBUILDREQUEST(SOCCancelBuildRequest mes)
handle the rare "cancel build request" message; usually not sent from server to client. |
protected void |
handleCHANGEFACE(SOCChangeFace mes)
handle the "change face" message |
protected void |
handleCHANNELS(SOCChannels mes)
handle the "list of channels" message |
protected void |
handleCHOOSEPLAYERREQUEST(SOCChoosePlayerRequest mes)
handle the "choose player request" message |
protected void |
handleCLEAROFFER(SOCClearOffer mes)
handle the "clear offer" message |
protected void |
handleCLEARTRADEMSG(SOCClearTradeMsg mes)
handle the "clear trade message" message |
protected void |
handleDELETECHANNEL(SOCDeleteChannel mes)
handle the "delete channel" message |
protected void |
handleDELETEGAME(SOCDeleteGame mes)
handle the "delete game" message |
protected void |
handleDEVCARD(SOCDevCard mes)
handle the "development card action" message |
protected void |
handleDEVCARDCOUNT(SOCDevCardCount mes)
handle the "number of development cards" message |
protected void |
handleDICERESULT(SOCDiceResult mes)
handle the "dice result" message |
protected void |
handleDISCARDREQUEST(SOCDiscardRequest mes)
handle the "discard request" message |
protected void |
handleFIRSTPLAYER(SOCFirstPlayer mes)
handle the "first player" message |
protected void |
handleGAMEMEMBERS(SOCGameMembers mes)
handle the "game members" message |
protected void |
handleGAMES(SOCGames mes)
handle the "list of games" message |
protected void |
handleGAMESTATE(SOCGameState mes)
handle the "game state" message |
protected void |
handleGAMESTATS(SOCGameStats mes)
handle the "game stats" message |
protected void |
handleGAMETEXTMSG(SOCGameTextMsg mes)
handle the "game text message" message |
protected void |
handleJOIN(SOCJoin mes)
handle the "join channel" message |
protected void |
handleJOINAUTH(SOCJoinAuth mes)
handle the "join authorization" message |
protected void |
handleJOINGAME(SOCJoinGame mes)
handle the "join game" message |
protected void |
handleJOINGAMEAUTH(SOCJoinGameAuth mes)
handle the "join game authorization" message |
protected void |
handleLARGESTARMY(SOCLargestArmy mes)
handle the "largest army" message |
protected void |
handleLEAVE(SOCLeave mes)
handle the "leave channel" message |
protected void |
handleLEAVEGAME(SOCLeaveGame mes)
handle the "leave game" message |
protected void |
handleLONGESTROAD(SOCLongestRoad mes)
handle the "longest road" message |
protected void |
handleMAKEOFFER(SOCMakeOffer mes)
handle the "make offer" message |
protected void |
handleMEMBERS(SOCMembers mes)
handle the "members" message |
protected void |
handleMOVEROBBER(SOCMoveRobber mes)
handle the "robber moved" message |
protected void |
handleNEWCHANNEL(SOCNewChannel mes)
handle the "new channel" message |
protected void |
handleNEWGAME(SOCNewGame mes)
handle the "new game" message |
static void |
handlePLAYERELEMENT_numKnights(SOCPlayerElement mes,
SOCPlayer pl,
SOCGame ga)
Update a player's amount of knights, and game's largest army, for handlePLAYERELEMENT(SOCPlayerElement). |
static void |
handlePLAYERELEMENT_numPieces(SOCPlayerElement mes,
SOCPlayer pl,
int pieceType)
Update a player's amount of a playing piece, for handlePLAYERELEMENT(SOCPlayerElement). |
static void |
handlePLAYERELEMENT_numRsrc(SOCPlayerElement mes,
SOCPlayer pl,
int rtype)
Update a player's amount of a resource, for handlePLAYERELEMENT(SOCPlayerElement). |
protected void |
handlePLAYERELEMENT(SOCPlayerElement mes)
handle the "player information" message |
protected void |
handlePOTENTIALSETTLEMENTS(SOCPotentialSettlements mes)
handle the "list of potential settlements" message |
protected void |
handlePUTPIECE(SOCPutPiece mes)
handle the "put piece" message |
protected void |
handleREJECTCONNECTION(SOCRejectConnection mes)
handle the "reject connection" message |
protected void |
handleREJECTOFFER(SOCRejectOffer mes)
handle the "reject offer" message |
protected void |
handleRESETBOARDAUTH(SOCResetBoardAuth mes)
handle board reset (new game with same players, same game name, new layout). |
protected void |
handleRESOURCECOUNT(SOCResourceCount mes)
handle "resource count" message |
protected void |
handleSETPLAYEDDEVCARD(SOCSetPlayedDevCard mes)
handle the "set played dev card flag" message |
protected void |
handleSETSEATLOCK(SOCSetSeatLock mes)
handle the "set seat lock" message |
protected void |
handleSETTURN(SOCSetTurn mes)
handle the "set turn" message |
protected void |
handleSITDOWN(SOCSitDown mes)
handle the "player sitting down" message |
protected void |
handleSTARTGAME(SOCStartGame mes)
handle the "start game" message |
protected void |
handleSTATUSMESSAGE(SOCStatusMessage mes)
handle the "status message" message |
protected void |
handleTEXTMSG(SOCTextMsg mes)
handle a text message |
protected void |
handleTURN(SOCTurn mes)
handle the "turn" message |
private void |
handleVERSION(boolean isLocal,
SOCVersion mes)
Handle the "version" message, server's version report. |
void |
leaveChannel(java.lang.String ch)
the user leaves the given channel |
void |
leaveGame(SOCGame ga)
the user leaves the given game |
void |
lockSeat(SOCGame ga,
int pn)
the user is locking a seat |
static void |
main(java.lang.String[] args)
for stand-alones |
void |
monopolyPick(SOCGame ga,
int res)
the user picked a resource to monopolize |
void |
moveRobber(SOCGame ga,
SOCPlayer pl,
int coord)
the player wants to move the robber |
void |
offerTrade(SOCGame ga,
SOCTradeOffer offer)
the user is making an offer to trade |
void |
playDevCard(SOCGame ga,
int dc)
the user wants to play a development card |
boolean |
put(java.lang.String s)
write a message to the net |
void |
putPiece(SOCGame ga,
SOCPlayingPiece pp)
put a piece on the board |
void |
rejectOffer(SOCGame ga)
the user is rejecting the current offers |
void |
resend()
resend the last message |
void |
rollDice(SOCGame ga)
the user rolls the dice |
void |
run()
continuously read from the net in a separate thread |
void |
sendText(SOCGame ga,
java.lang.String me)
send a text message to the people in the game |
void |
sitDown(SOCGame ga,
int pn)
the user sits down to play |
void |
startGame(SOCGame ga)
the user is starting the game |
void |
treat(SOCMessage mes)
Treat the incoming messages. |
void |
unlockSeat(SOCGame ga,
int pn)
the user is unlocking a seat |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected static java.lang.String STATSPREFEX
protected java.lang.String doc
protected java.lang.String lastMessage
protected java.lang.String host
protected int port
protected java.lang.String strSocketName
protected java.net.Socket s
protected java.io.DataInputStream in
protected java.io.DataOutputStream out
protected LocalStringConnection sLocal
protected int sVersion
protected int sLocalVersion
protected java.lang.Thread reader
protected java.lang.Exception ex
protected boolean connected
protected boolean rejected
protected java.lang.String nickname
protected java.lang.String password
protected boolean gotPassword
protected java.util.Hashtable channels
protected java.util.Hashtable games
| Constructor Detail |
public SOCDisplaylessPlayerClient()
public SOCDisplaylessPlayerClient(java.lang.String h,
int p,
boolean visual)
h - hostp - portvisual - true if this client is visual
public SOCDisplaylessPlayerClient(java.lang.String s,
boolean visual)
s - the stringport that the server listens onvisual - true if this client is visual| Method Detail |
public java.lang.String getNickname()
public void run()
run in interface java.lang.Runnablepublic void resend()
public boolean put(java.lang.String s)
s - the message
public void treat(SOCMessage mes)
SOCMessage.toMsg(String)).
mes - the messageprotected void handleSTATUSMESSAGE(SOCStatusMessage mes)
mes - the messageprotected void handleJOINAUTH(SOCJoinAuth mes)
mes - the message
private void handleVERSION(boolean isLocal,
SOCVersion mes)
isLocal - Is the server local, or remote? Client can be connected
only to local, or remote.mes - the messsageprotected void handleJOIN(SOCJoin mes)
mes - the messageprotected void handleMEMBERS(SOCMembers mes)
mes - the messageprotected void handleNEWCHANNEL(SOCNewChannel mes)
mes - the messageprotected void handleCHANNELS(SOCChannels mes)
mes - the messageprotected void handleBCASTTEXTMSG(SOCBCastTextMsg mes)
mes - the messageprotected void handleTEXTMSG(SOCTextMsg mes)
mes - the messageprotected void handleLEAVE(SOCLeave mes)
mes - the messageprotected void handleDELETECHANNEL(SOCDeleteChannel mes)
mes - the messageprotected void handleGAMES(SOCGames mes)
mes - the messageprotected void handleJOINGAMEAUTH(SOCJoinGameAuth mes)
mes - the messageprotected void handleJOINGAME(SOCJoinGame mes)
mes - the messageprotected void handleLEAVEGAME(SOCLeaveGame mes)
mes - the messageprotected void handleNEWGAME(SOCNewGame mes)
mes - the messageprotected void handleDELETEGAME(SOCDeleteGame mes)
mes - the messageprotected void handleGAMEMEMBERS(SOCGameMembers mes)
mes - the messageprotected void handleGAMESTATS(SOCGameStats mes)
protected void handleGAMETEXTMSG(SOCGameTextMsg mes)
mes - the messageprotected void handleSITDOWN(SOCSitDown mes)
mes - the messageprotected void handleBOARDLAYOUT(SOCBoardLayout mes)
mes - the messageprotected void handleSTARTGAME(SOCStartGame mes)
mes - the messageprotected void handleGAMESTATE(SOCGameState mes)
mes - the messageprotected void handleSETTURN(SOCSetTurn mes)
mes - the messageprotected void handleFIRSTPLAYER(SOCFirstPlayer mes)
mes - the messageprotected void handleTURN(SOCTurn mes)
mes - the messageprotected void handlePLAYERELEMENT(SOCPlayerElement mes)
mes - the message
public static void handlePLAYERELEMENT_numPieces(SOCPlayerElement mes,
SOCPlayer pl,
int pieceType)
handlePLAYERELEMENT(SOCPlayerElement).
To avoid code duplication, also called from
SOCPlayerClient.handlePLAYERELEMENT(SOCPlayerElement)
and SOCRobotBrain.run().
mes - Message with amount and action (SET/GAIN/LOSE)pl - Player to updatepieceType - Playing piece type, as in SOCPlayingPiece.ROAD
public static void handlePLAYERELEMENT_numKnights(SOCPlayerElement mes,
SOCPlayer pl,
SOCGame ga)
handlePLAYERELEMENT(SOCPlayerElement).
To avoid code duplication, also called from
SOCPlayerClient.handlePLAYERELEMENT(SOCPlayerElement)
and SOCRobotBrain.run().
mes - Message with amount and action (SET/GAIN/LOSE)pl - Player to updatega - Game of player
public static void handlePLAYERELEMENT_numRsrc(SOCPlayerElement mes,
SOCPlayer pl,
int rtype)
handlePLAYERELEMENT(SOCPlayerElement).
SOCPlayerElement.LOSE action, and the player does not have enough of that type,
the rest are taken from the player's UNKNOWN amount.
To avoid code duplication, also called from
SOCPlayerClient.handlePLAYERELEMENT(SOCPlayerElement)
and SOCRobotBrain.run().
mes - Message with amount and action (SET/GAIN/LOSE)pl - Player to updatertype - Type of resource, like SOCResourceConstants.CLAYprotected void handleRESOURCECOUNT(SOCResourceCount mes)
mes - the messageprotected void handleDICERESULT(SOCDiceResult mes)
mes - the messageprotected void handlePUTPIECE(SOCPutPiece mes)
mes - the messageprotected void handleCANCELBUILDREQUEST(SOCCancelBuildRequest mes)
- When sent from client to server, CANCELBUILDREQUEST means the player has changed their mind about spending resources to build a piece. Only allowed during normal game play (PLACING_ROAD, PLACING_SETTLEMENT, or PLACING_CITY).
When sent from server to client:
- During game startup (START1B or START2B):
Sent from server, CANCELBUILDREQUEST means the current player
wants to undo the placement of their initial settlement.
- During piece placement (PLACING_ROAD, PLACING_CITY, PLACING_SETTLEMENT, PLACING_FREE_ROAD1 or PLACING_FREE_ROAD2):
Sent from server, CANCELBUILDREQUEST means the player has sent an illegal PUTPIECE (bad building location). Humans can probably decide a better place to put their road, but robots must cancel the build request and decide on a new plan.
Our client can ignore this case, because the server also sends a text message that the human player is capable of reading and acting on.
mes - the messageprotected void handleMOVEROBBER(SOCMoveRobber mes)
mes - the messageprotected void handleDISCARDREQUEST(SOCDiscardRequest mes)
mes - the messageprotected void handleCHOOSEPLAYERREQUEST(SOCChoosePlayerRequest mes)
mes - the messageprotected void handleMAKEOFFER(SOCMakeOffer mes)
mes - the messageprotected void handleCLEAROFFER(SOCClearOffer mes)
mes - the messageprotected void handleREJECTOFFER(SOCRejectOffer mes)
mes - the messageprotected void handleCLEARTRADEMSG(SOCClearTradeMsg mes)
mes - the messageprotected void handleDEVCARDCOUNT(SOCDevCardCount mes)
mes - the messageprotected void handleDEVCARD(SOCDevCard mes)
mes - the messageprotected void handleSETPLAYEDDEVCARD(SOCSetPlayedDevCard mes)
mes - the messageprotected void handlePOTENTIALSETTLEMENTS(SOCPotentialSettlements mes)
mes - the messageprotected void handleCHANGEFACE(SOCChangeFace mes)
mes - the messageprotected void handleREJECTCONNECTION(SOCRejectConnection mes)
mes - the messageprotected void handleLONGESTROAD(SOCLongestRoad mes)
mes - the messageprotected void handleLARGESTARMY(SOCLargestArmy mes)
mes - the messageprotected void handleSETSEATLOCK(SOCSetSeatLock mes)
mes - the messageprotected void handleRESETBOARDAUTH(SOCResetBoardAuth mes)
mes - the messageSOCServer.resetBoardAndNotify(String, int),
SOCGame.resetAsCopy()
public void chSend(java.lang.String ch,
java.lang.String mes)
ch - the name of the channelmes - the messagepublic void leaveChannel(java.lang.String ch)
ch - the name of the channelprotected void disconnect()
public void buyDevCard(SOCGame ga)
ga - the game
public void buildRequest(SOCGame ga,
int piece)
ga - the gamepiece - the type of piece from SOCPlayingPiece
public void cancelBuildRequest(SOCGame ga,
int piece)
ga - the gamepiece - the type of piece from SOCPlayingPiece
public void putPiece(SOCGame ga,
SOCPlayingPiece pp)
ga - the game where the action is taking placepp - the piece being placed
public void moveRobber(SOCGame ga,
SOCPlayer pl,
int coord)
ga - the gamepl - the playercoord - where the player wants the robber
public void sendText(SOCGame ga,
java.lang.String me)
ga - the gameme - the messagepublic void leaveGame(SOCGame ga)
ga - the game
public void sitDown(SOCGame ga,
int pn)
ga - the gamepn - the number of the seat where the user wants to sitpublic void startGame(SOCGame ga)
ga - the gamepublic void rollDice(SOCGame ga)
ga - the gamepublic void endTurn(SOCGame ga)
ga - the game
public void discard(SOCGame ga,
SOCResourceSet rs)
ga - the game
public void choosePlayer(SOCGame ga,
int pn)
ga - the gamepn - the player idpublic void rejectOffer(SOCGame ga)
ga - the game
public void acceptOffer(SOCGame ga,
int from)
ga - the gamefrom - the number of the player that is making the offerpublic void clearOffer(SOCGame ga)
ga - the game
public void bankTrade(SOCGame ga,
SOCResourceSet give,
SOCResourceSet get)
ga - the gamegive - what is being offeredget - what the player wants
public void offerTrade(SOCGame ga,
SOCTradeOffer offer)
ga - the gameoffer - the trade offer
public void playDevCard(SOCGame ga,
int dc)
ga - the gamedc - the type of development card
public void discoveryPick(SOCGame ga,
SOCResourceSet rscs)
ga - the gamerscs - the resources
public void monopolyPick(SOCGame ga,
int res)
ga - the gameres - the resource
public void changeFace(SOCGame ga,
int id)
ga - the gameid - the image id
public void lockSeat(SOCGame ga,
int pn)
ga - the gamepn - the seat number
public void unlockSeat(SOCGame ga,
int pn)
ga - the gamepn - the seat numberpublic void destroy()
public static void main(java.lang.String[] args)
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||