soc.message
Class SOCVersion

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

public class SOCVersion
extends SOCMessage

This message sends the server's version and features, or client's version and locale, to the other side of the connection. VERSION is the first message sent from client to server. The server also sends its version to the client early, not in response to client's VERSION message. Version numbers are read via Version.

Before 2.0.00, the client did not send locale; new servers should probably assume en_US since older versions had all messages in english. For robots the locale field is ignored at server, because bots don't parse server text messages; sending a SOCImARobot message will clear the robot client's locale to null at the server.

Before 1.1.19, the server did not send its active optional features; new clients of older servers should use the SOCServerFeatures(true) constructor to set the default features active.

Before 1.1.06, in SOCPlayerClient, this was sent first from server to client, then client responded. Robot clients have always sent first since the introduction in 1.1.00 of client-server versioning (2008-08-07).

Since:
1.1.00
Version:
2.0.00
Author:
Jeremy D Monin <jeremy@nand.net>
See Also:
Serialized Form

Field Summary
 java.lang.String localeOrFeats
          Dual-purpose field: Client's JVM locale, or null, as in Locale.toString(); Or server's active optional features, or null, as in SOCServerFeatures.getEncodedList().
private static long serialVersionUID
           
private  java.lang.String versBuild
          Version build, or null, as in Version.buildnum()
private  int versNum
          Version number, as in Version.versionNumber()
private  java.lang.String versStr
          Version display string, as in Version.version()
 
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
SOCVersion(int verNum, java.lang.String verStr, java.lang.String verBuild, java.lang.String verlocaleOrFeats)
          Create a Version message.
 
Method Summary
 java.lang.String getBuild()
           
 int getMinimumVersion()
          Minimum version where this message type is used.
 int getVersionNumber()
           
 java.lang.String getVersionString()
           
static SOCVersion parseDataStr(java.lang.String s)
          Parse the command String into a Version message
 java.lang.String toCmd()
          VERSION SEP vernum SEP2 verstr SEP2 build SEP2 localeOrFeats; build,localeOrFeats may be blank
static java.lang.String toCmd(int verNum, java.lang.String verStr, java.lang.String verBuild, java.lang.String verlocaleOrFeats)
          VERSION SEP vernum SEP2 verstr SEP2 build SEP2 localeOrFeats; build,localeOrFeats may be blank
 java.lang.String toString()
          Simple human-readable representation, used for debug purposes.
 
Methods inherited from class soc.message.SOCMessage
arrayIntoStringBuf, enumIntoStringBuf, getClassNameShort, getMaximumVersion, 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
See Also:
Constant Field Values

versStr

private java.lang.String versStr
Version display string, as in Version.version()


versNum

private int versNum
Version number, as in Version.versionNumber()


versBuild

private java.lang.String versBuild
Version build, or null, as in Version.buildnum()


localeOrFeats

public final java.lang.String localeOrFeats
Dual-purpose field: Client's JVM locale, or null, as in Locale.toString(); Or server's active optional features, or null, as in SOCServerFeatures.getEncodedList(). Locale not sent from server or from jsettlers clients older than 2.0.00. Features not sent from servers older than 1.1.19. (In v1.1.19 this field is called feats.) See class javadoc for handling older clients or servers when this field is null.

Since:
2.0.00
Constructor Detail

SOCVersion

public SOCVersion(int verNum,
                  java.lang.String verStr,
                  java.lang.String verBuild,
                  java.lang.String verlocaleOrFeats)
           throws java.lang.IllegalArgumentException
Create a Version message.

Parameters:
verNum - The version number, as in Version.versionNumber()
verStr - The version display string, as in Version.version()
verBuild - The version build, or null, as in Version.buildnum()
verlocaleOrFeats - The client's JVM locale, or null, as in Locale.toString(); not sent by jsettlers clients older than 2.0.00. Or the server's active optional features, or null, as in SOCServerFeatures.getEncodedList(); not sent by servers older than 1.1.19. Server can send this to a client older than 1.1.19, it is safely ignored.
Throws:
java.lang.IllegalArgumentException - if verBuild is null and verlocaleOrFeats != null; not supported by message encoding.
Method Detail

getVersionNumber

public int getVersionNumber()
Returns:
the version number, as in Version.versionNumber()

getVersionString

public java.lang.String getVersionString()
Returns:
the version display string, as in Version.version()

getBuild

public java.lang.String getBuild()
Returns:
the build, as in Version.buildnum(), or null

toCmd

public java.lang.String toCmd()
VERSION SEP vernum SEP2 verstr SEP2 build SEP2 localeOrFeats; build,localeOrFeats may be blank

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

toCmd

public static java.lang.String toCmd(int verNum,
                                     java.lang.String verStr,
                                     java.lang.String verBuild,
                                     java.lang.String verlocaleOrFeats)
                              throws java.lang.IllegalArgumentException
VERSION SEP vernum SEP2 verstr SEP2 build SEP2 localeOrFeats; build,localeOrFeats may be blank

Parameters:
verNum - the version number, like 1100 for 1.1.00, as in Version.versionNumber()
verStr - the version as string, like "1.1.00"
verBuild - the version build, or null, from Version.buildnum()
verlocaleOrFeats - The client's JVM locale, or null, as in Locale.toString(); not sent by jsettlers clients older than 2.0.00. Or the server's active optional features, or null, as in SOCServerFeatures.getEncodedList(); not sent by servers older than 1.1.19. Server can send this to a client older than 1.1.19, it is safely ignored.
Returns:
the command string
Throws:
java.lang.IllegalArgumentException - if verBuild is null and verlocaleOrFeats != null; not supported by message encoding.

parseDataStr

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

Parameters:
s - the String to parse
Returns:
a Version message

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

getMinimumVersion

public int getMinimumVersion()
Minimum version where this message type is used. VERSION introduced in 1.1.00 for client/server versioning.

Overrides:
getMinimumVersion in class SOCMessage
Returns:
Version number, 1100 for JSettlers 1.1.00.