soc.message
Class SOCImARobot

java.lang.Object
  extended by soc.message.SOCMessage
      extended by soc.message.SOCImARobot
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class SOCImARobot
extends SOCMessage

This message tells the server that the client is a robot.

The server is distributed with the original robot AI, and this permits optimized communications and server simplifications. So, the server requires that robot clients are the same version as the server.

In 1.1.09 and later, 3rd-party robots can connect and be treated as robots. (For example, games where all humans leave, but robots remain, are stopped.) The 3rd-party robots can report any version, just like human player clients.

The IMAROBOT message includes a getRBClass() parameter to indicate whether the robot is 3rd-party or is the original built-in AI.

In 1.1.19 and later, the IMAROBOT message includes a shared secret cookie to authenticate the bot to the server.

Author:
Robert S Thomas
See Also:
Serialized Form

Field Summary
private  java.lang.String cookie
          The security cookie value expected by the server.
private  java.lang.String nickname
          Nickname of the robot
private  java.lang.String rbclass
          The robot's brain class, to show 3rd-party robots.
static java.lang.String RBCLASS_BUILTIN
          Name of built-in robot brain class.
private static long serialVersionUID
          Version 1.1.09: add rbclass.
 
Fields inherited from class soc.message.SOCMessage
ACCEPTOFFER, ADMINPING, ADMINRESET, AUTHREQUEST, BANKTRADE, BCASTTEXTMSG, BOARDLAYOUT, BOARDLAYOUT2, BOARDSPECIALEDGE, BUILDREQUEST, BUYCARDREQUEST, CANCELBUILDREQUEST, CHANGEFACE, CHANNELS, CHOOSEPLAYER, CHOOSEPLAYERREQUEST, CLEAROFFER, CLEARTRADEMSG, CREATEACCOUNT, DEBUGFREEPLACE, DELETECHANNEL, DELETEGAME, DEVCARDACTION, DEVCARDCOUNT, DICERESULT, DICERESULTRESOURCES, DISCARD, DISCARDREQUEST, DISCOVERYPICK, ENDTURN, FIRSTPLAYER, GAME_NONE, GAMEMEMBERS, GAMEOPTIONGETDEFAULTS, GAMEOPTIONGETINFOS, GAMEOPTIONINFO, GAMES, GAMESERVERTEXT, GAMESTATE, GAMESTATS, GAMESWITHOPTIONS, GAMETEXTMSG, IMAROBOT, INVENTORYITEMACTION, JOIN, JOINAUTH, JOINGAME, JOINGAMEAUTH, LARGESTARMY, LASTSETTLEMENT, LEAVE, LEAVEALL, LEAVEGAME, LEGALEDGES, LOCALIZEDSTRINGS, LONGESTROAD, MAKEOFFER, MEMBERS, messageType, MONOPOLYPICK, MOVEPIECE, MOVEPIECEREQUEST, MOVEROBBER, NEWCHANNEL, NEWGAME, NEWGAMEWITHOPTIONS, NEWGAMEWITHOPTIONSREQUEST, NULLMESSAGE, PICKRESOURCES, PICKRESOURCESREQUEST, PIECEVALUE, PLAYDEVCARDREQUEST, PLAYERELEMENT, PLAYERELEMENTS, PLAYERSTATS, POTENTIALSETTLEMENTS, PUTPIECE, REJECTCONNECTION, REJECTOFFER, REMOVEPIECE, RESETBOARDAUTH, RESETBOARDREJECT, RESETBOARDREQUEST, RESETBOARDVOTE, RESETBOARDVOTEREQUEST, RESOURCECOUNT, REVEALFOGHEX, ROBOTDISMISS, ROBOTJOINGAMEREQUEST, ROLLDICE, ROLLDICEPROMPT, ROLLDICEREQUEST, SCENARIOINFO, sep, sep_char, sep2, sep2_char, SERVERPING, SETPLAYEDDEVCARD, SETSEATLOCK, SETSPECIALITEM, SETTURN, SETUPDONE, SIMPLEACTION, SIMPLEREQUEST, SITDOWN, STARTGAME, STATUSMESSAGE, SVPTEXTMSG, TEXTMSG, TIMINGPING, TURN, UPDATEROBOTPARAMS, VERSION
 
Constructor Summary
SOCImARobot(java.lang.String nn, java.lang.String cookie, java.lang.String rbclass)
          Create a ImARobot message.
 
Method Summary
 java.lang.String getCookie()
          Get the security cookie to send to the server for this connection.
 java.lang.String getNickname()
           
 java.lang.String getRBClass()
           
static SOCImARobot parseDataStr(java.lang.String s)
          Parse the command String into a ImARobot message
 java.lang.String toCmd()
          IMAROBOT sep nickname
static java.lang.String toCmd(java.lang.String nn, java.lang.String cookie, java.lang.String rbclass)
          IMAROBOT sep nickname sep2 cookie sep2 rbclass
 java.lang.String toString()
          Simple human-readable representation, used for debug purposes.
 
Methods inherited from class soc.message.SOCMessage
arrayIntoStringBuf, enumIntoStringBuf, getClassNameShort, getMaximumVersion, getMinimumVersion, getType, isSingleLineAndSafe, isSingleLineAndSafe, toMsg
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Version 1.1.09: add rbclass. This is 1st change since the original class.

Version 1.1.19: add cookie.

Since:
1.1.09
See Also:
Constant Field Values

RBCLASS_BUILTIN

public static final java.lang.String RBCLASS_BUILTIN
Name of built-in robot brain class. This robot is the original robot, distributed with the JSettlers server, which permits some optimized communications. Other (3rd-party) robots must use a different class in their IMAROBOT messages. See the class javadoc for more details.

Since:
1.1.09
See Also:
Constant Field Values

nickname

private java.lang.String nickname
Nickname of the robot


cookie

private final java.lang.String cookie
The security cookie value expected by the server. It isn't sent encrypted and is a weak "shared secret".

Since:
1.1.19

rbclass

private java.lang.String rbclass
The robot's brain class, to show 3rd-party robots. The built-in robot is RBCLASS_BUILTIN. If cookie != null, then rbclass != null.

Since:
1.1.09
Constructor Detail

SOCImARobot

public SOCImARobot(java.lang.String nn,
                   java.lang.String cookie,
                   java.lang.String rbclass)
            throws java.lang.IllegalArgumentException
Create a ImARobot message.

Parameters:
nn - nickname
cookie - security cookie to send to the server for this connection; required by server v1.1.19 and higher, or null. Must pass SOCMessage.isSingleLineAndSafe(String) unless null.
rbclass - robot brain class, such as RBCLASS_BUILTIN. Other (3rd-party) robots must use a different rbclass in their IMAROBOT messages. Must not be null if cookie is null.
Throws:
java.lang.IllegalArgumentException - if cookie is non-null, and cookie fails SOCMessage.isSingleLineAndSafe(String) or rbclass is null.
Since:
1.1.09
Method Detail

getNickname

public java.lang.String getNickname()
Returns:
the nickname

getCookie

public java.lang.String getCookie()
Get the security cookie to send to the server for this connection. It isn't sent encrypted and is a weak "shared secret". Required by server v1.1.19 and higher.

Returns:
the cookie
Since:
1.1.19

getRBClass

public java.lang.String getRBClass()
Returns:
the robot brain class, or null for pre-1.1.09 built-in robots
Since:
1.1.09

toCmd

public java.lang.String toCmd()
IMAROBOT sep nickname

Specified by:
toCmd in class SOCMessage
Returns:
the command String

toCmd

public static java.lang.String toCmd(java.lang.String nn,
                                     java.lang.String cookie,
                                     java.lang.String rbclass)
IMAROBOT sep nickname sep2 cookie sep2 rbclass

Parameters:
nn - the nickname
cookie - the security cookie
rbclass - the robot class
Returns:
the command string

parseDataStr

public static SOCImARobot parseDataStr(java.lang.String s)
Parse the command String into a ImARobot message

Parameters:
s - the String to parse
Returns:
a ImARobot message, or null of the data is garbled

toString

public java.lang.String toString()
Description copied from class: SOCMessage
Simple human-readable representation, used for debug purposes.

Specified by:
toString in class SOCMessage
Returns:
a human readable form of the message