|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectsoc.message.SOCMessage
Messages used for game data, events, and chatting on a channel.
No objects, only strings and integers, are to be sent over the network
between servers and clients! Your game's code must guarantee that no string
sent contains a separator character (sep_char or sep2_char).
Text announcements (SOCGameTextMsg) are often sent along with
data messages.
The message data is sent over the network as type ID + data strings built by each SOCMessage subclass's toCmd() method.
On the remote end, it's reconstructed to a new instance of the
appropriate SOCMessage subclass, by the subclass' required method
static SOCMessageSubclass parseDataStr(String).
parseDataStr is called from toMsg(String) in this class.
The client receives messages in SOCPlayerClient.treat(SOCMessage, boolean).
The server receives messages in SOCServer.processCommand(String, StringConnection).
To create a new message type:
toMsg(String). Again, note the version.
SOCDiceResult and SOCSetTurn are good example subclasses.)
Template parent-classes can help; the example subclasses extend them.
Be sure to override the minimum version reported in getMinimumVersion().
Note: Most things added to SOCPlayerClient.treat should also be added to
SOCDisplaylessPlayerClient.treat(SOCMessage),
to SOCRobotClient.treat(SOCMessage),
and possibly to SOCRobotBrain.run().
Backwards compatability: Unknown message types are ignored by client and by server.
Technically they are returned as null from toMsg(String) if the local copy
of SOCMessage doesn't know that message type.
Format:
For most messages, at most one sep token per message, which separates the messagetype number
from the message data; multiple SEP2 are allowed after SEP.
For multi-messages, multiple SEP are allowed; see SOCMessageMulti.
| Field Summary | |
static int |
ACCEPTOFFER
|
static int |
ADMINPING
|
static int |
ADMINRESET
|
static int |
BANKTRADE
|
static int |
BCASTTEXTMSG
|
static int |
BOARDLAYOUT
|
static int |
BUILDREQUEST
|
static int |
BUYCARDREQUEST
|
static int |
CANCELBUILDREQUEST
|
static int |
CHANGEFACE
|
static int |
CHANNELS
|
static int |
CHOOSEPLAYER
|
static int |
CHOOSEPLAYERREQUEST
|
static int |
CLEAROFFER
|
static int |
CLEARTRADEMSG
|
static int |
CREATEACCOUNT
|
static int |
DELETECHANNEL
|
static int |
DELETEGAME
|
static int |
DEVCARD
|
static int |
DEVCARDCOUNT
|
static int |
DICERESULT
|
static int |
DISCARD
|
static int |
DISCARDREQUEST
|
static int |
DISCOVERYPICK
|
static int |
ENDTURN
|
static int |
FIRSTPLAYER
|
static int |
GAMEMEMBERS
|
static int |
GAMES
|
static int |
GAMESTATE
|
static int |
GAMESTATS
|
static int |
GAMETEXTMSG
|
static int |
IMAROBOT
|
static int |
JOIN
|
static int |
JOINAUTH
|
static int |
JOINGAME
|
static int |
JOINGAMEAUTH
|
static int |
JOINGAMEREQUEST
|
static int |
LARGESTARMY
|
static int |
LASTSETTLEMENT
|
static int |
LEAVE
|
static int |
LEAVEALL
|
static int |
LEAVEGAME
|
static int |
LONGESTROAD
|
static int |
MAKEOFFER
|
static int |
MEMBERS
|
protected int |
messageType
An ID identifying the type of message |
static int |
MONOPOLYPICK
|
static int |
MOVEROBBER
|
static int |
NEWCHANNEL
|
static int |
NEWGAME
|
static int |
NULLMESSAGE
message type IDs |
static int |
PLAYDEVCARDREQUEST
|
static int |
PLAYERELEMENT
|
static int |
POTENTIALSETTLEMENTS
|
static int |
PUTPIECE
|
static int |
REJECTCONNECTION
|
static int |
REJECTOFFER
|
static int |
RESETBOARDAUTH
|
static int |
RESETBOARDREJECT
|
static int |
RESETBOARDREQUEST
|
static int |
RESETBOARDVOTE
|
static int |
RESETBOARDVOTEREQUEST
|
static int |
RESOURCECOUNT
|
static int |
ROBOTDISMISS
|
static int |
ROLLDICE
|
static int |
ROLLDICEPROMPT
|
static int |
ROLLDICEREQUEST
|
static java.lang.String |
sep
Token seperators. |
static char |
sep_char
main separator token sep, as character |
static java.lang.String |
sep2
secondary separator token SEP2, as string |
static char |
sep2_char
secondary separator token sep2, as character |
static int |
SERVERPING
|
static int |
SETPLAYEDDEVCARD
|
static int |
SETSEATLOCK
|
static int |
SETTURN
|
static int |
SETUPDONE
|
static int |
SITDOWN
|
static int |
STARTGAME
|
static int |
STATUSMESSAGE
|
static int |
TEXTMSG
|
static int |
TURN
|
static int |
UPDATEROBOTPARAMS
|
static int |
VERSION
|
| Constructor Summary | |
SOCMessage()
|
|
| Method Summary | |
int |
getMaximumVersion()
To identify obsolete message types, give the maximum version where this type is used. |
int |
getMinimumVersion()
To identify new message types, give the minimum version where this type is used. |
int |
getType()
|
abstract java.lang.String |
toCmd()
Converts the contents of this message into a String that can be transferred by a client or server. |
static SOCMessage |
toMsg(java.lang.String s)
Convert a string into a SOCMessage. |
static java.lang.String[] |
toSingleElemArray(java.lang.String s)
Utility, place one string into a new single-element array. |
abstract java.lang.String |
toString()
Simple human-readable representation, used for debug purposes. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int NULLMESSAGE
public static final int NEWCHANNEL
public static final int MEMBERS
public static final int CHANNELS
public static final int JOIN
public static final int TEXTMSG
public static final int LEAVE
public static final int DELETECHANNEL
public static final int LEAVEALL
public static final int PUTPIECE
public static final int GAMETEXTMSG
public static final int LEAVEGAME
public static final int SITDOWN
public static final int JOINGAME
public static final int BOARDLAYOUT
public static final int DELETEGAME
public static final int NEWGAME
public static final int GAMEMEMBERS
public static final int STARTGAME
public static final int GAMES
public static final int JOINAUTH
public static final int JOINGAMEAUTH
public static final int IMAROBOT
public static final int JOINGAMEREQUEST
public static final int PLAYERELEMENT
public static final int GAMESTATE
public static final int TURN
public static final int SETUPDONE
public static final int DICERESULT
public static final int DISCARDREQUEST
public static final int ROLLDICEREQUEST
public static final int ROLLDICE
public static final int ENDTURN
public static final int DISCARD
public static final int MOVEROBBER
public static final int CHOOSEPLAYER
public static final int CHOOSEPLAYERREQUEST
public static final int REJECTOFFER
public static final int CLEAROFFER
public static final int ACCEPTOFFER
public static final int BANKTRADE
public static final int MAKEOFFER
public static final int CLEARTRADEMSG
public static final int BUILDREQUEST
public static final int CANCELBUILDREQUEST
public static final int BUYCARDREQUEST
public static final int DEVCARD
public static final int DEVCARDCOUNT
public static final int SETPLAYEDDEVCARD
public static final int PLAYDEVCARDREQUEST
public static final int DISCOVERYPICK
public static final int MONOPOLYPICK
public static final int FIRSTPLAYER
public static final int SETTURN
public static final int ROBOTDISMISS
public static final int POTENTIALSETTLEMENTS
public static final int CHANGEFACE
public static final int REJECTCONNECTION
public static final int LASTSETTLEMENT
public static final int GAMESTATS
public static final int BCASTTEXTMSG
public static final int RESOURCECOUNT
public static final int ADMINPING
public static final int ADMINRESET
public static final int LONGESTROAD
public static final int LARGESTARMY
public static final int SETSEATLOCK
public static final int STATUSMESSAGE
public static final int CREATEACCOUNT
public static final int UPDATEROBOTPARAMS
public static final int ROLLDICEPROMPT
public static final int RESETBOARDREQUEST
public static final int RESETBOARDAUTH
public static final int RESETBOARDVOTEREQUEST
public static final int RESETBOARDVOTE
public static final int RESETBOARDREJECT
public static final int VERSION
public static final int SERVERPING
public static final java.lang.String sep
SOCMessageMulti.
public static final java.lang.String sep2
public static final char sep_char
sep, as character
public static final char sep2_char
sep2, as character
protected int messageType
| Constructor Detail |
public SOCMessage()
| Method Detail |
public int getType()
public int getMinimumVersion()
public int getMaximumVersion()
Integer.MAX_VALUE.
Integer.MAX_VALUE.public abstract java.lang.String toCmd()
For most message types, at most one sep token is allowed,
separating the type ID from the rest of the parameters.
For multi-messages (@link SOCMessageMulti}, multiple sep tokens
are allowed. Multi-messages are parsed with:
static SOCMessageSubclass parseDataStr(String[])
public abstract java.lang.String toString()
public static java.lang.String[] toSingleElemArray(java.lang.String s)
SOCMessageMulti parsing.
s - String to place into array, or null
public static SOCMessage toMsg(java.lang.String s)
s - String to convert
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||