|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object soc.server.SOCClientData
public class SOCClientData
The server's place to track client-specific information across games. The win-loss count is kept here. Not tied to any database; information here is only for the current session, not persistent across disconnects/reconnects by clients.
Nested Class Summary | |
---|---|
private static class |
SOCClientData.SOCCDCliVersionTask
TimerTask at client connect, to guess the client version if it isn't sent soon enough. |
Field Summary | |
---|---|
boolean |
checkedLocaleScenStrings
If true we've called SOCServer.clientHasLocalizedStrs_gameScenarios(StringConnection) ,
storing the result in localeHasScenStrings . |
private SOCClientData.SOCCDCliVersionTask |
cliVersionTask
TimerTask for connect-time client-version timer |
private java.lang.Object |
countFieldSync
Synchronization for win-loss count and other counter fields |
private int |
currentCreatedChannels
Number of games/channels this client has created, which currently exist (not deleted) |
private int |
currentCreatedGames
Number of games/channels this client has created, which currently exist (not deleted) |
long |
disconnectLastPingMillis
Are we considering a request to disconnect this client? If so, the time we sent a ping (and awaiting a reply). |
boolean |
isBuiltInRobot
Is this robot connection the built-in robot (not a 3rd-party), with the original AI? |
boolean |
isRobot
Is this connection a robot? |
java.util.Locale |
locale
Client's reported JVM locale, or null , as in Locale.getDefault() . |
boolean |
localeHasScenStrings
If true we've called SOCServer.clientHasLocalizedStrs_gameScenarios(StringConnection) ,
and this client's locale is not null and has at least some localized scenario strings
(see that method's javadoc for details). |
java.lang.String |
localeStr
Client's reported JVM locale, or null , as in Locale.toString() . |
private int |
losses
Number of games won and lost since client connected |
java.lang.String |
robot3rdPartyBrainClass
For 3rd-party robots, their type (brain class). |
java.util.Map<java.lang.String,java.lang.String> |
scenariosInfoSent
The SOCScenario keynames for which we've
sent localized strings or all scenario info fields. |
static java.lang.String |
SENT_SCEN_INFO
For a scenario keyname in scenariosInfoSent , value indicating that the client
was sent all scenario info fields (not only localized scenario strings). |
static java.lang.String |
SENT_SCEN_STRINGS
For a scenario keyname in scenariosInfoSent , value indicating that the client
was sent localized scenario strings (not all scenario info fields), or that the client
requested them and no localized strings were found for that scenario. |
boolean |
sentAllScenarioInfo
True if we've sent all updated SOCScenario info. |
boolean |
sentAllScenarioStrings
True if we've sent localized strings for all SOCScenario s. |
private boolean |
sentGameList
Has the server's game list been sent to the client yet? Please synchronize on SOCGameList.takeMonitor() / releaseMonitor. |
boolean |
wantsI18N
If this flag is set, client has determined it wants localized strings (I18N), and asked for them early in the connect process by sending a message that had SOCGameOptionGetInfos.hasTokenGetI18nDescs() true. |
private int |
wins
Number of games won and lost since client connected |
Constructor Summary | |
---|---|
SOCClientData()
|
Method Summary | |
---|---|
void |
clearVersionTimer()
Cancel the version timer, don't fire it. |
void |
copyClientPlayerStats(SOCClientData source)
Copy the client's win-loss record from another SOCClientData. |
void |
createdChannel()
Client has created a channel; update the count. |
void |
createdGame()
Client has created a game; update the count. |
void |
deletedChannel()
Client has deleted a channel they created; update the count. |
void |
deletedGame()
Client has deleted a game they created; update the count. |
int |
getcurrentCreatedChannels()
|
int |
getCurrentCreatedGames()
|
int |
getLosses()
|
int |
getWins()
|
boolean |
hasSentGameList()
Has the server's game list been sent to the client yet? Please synchronize on SOCGameList.takeMonitor() / releaseMonitor. |
void |
lostGame()
Client has lost a game; update win-loss count. |
void |
setSentGameList()
Set flag: Has the server's game list been sent to the client yet? Please synchronize on SOCGameList.takeMonitor() / releaseMonitor. |
void |
setVersionTimer(SOCServer sr,
StringConnection con)
Set up the version timer. |
void |
wonGame()
Client has won a game; update win-loss count. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int wins
private int losses
public java.util.Locale locale
null
, as in Locale.getDefault()
.
Sent via Locale.toString()
as part of the SOCVersion message.
Kept as localeStr
and also parsed to this field.
Not sent from jsettlers clients older than 2.0.00;
if null, should probably assume en_US
since older versions had all messages in english.
Bots always use a null
locale; they don't care about message text contents, and a
null locale means they won't set any SOCGame.hasMultiLocales
flag by joining.
wantsI18N
public java.lang.String localeStr
null
, as in Locale.toString()
.
Sent as part of the SOCVersion message, kept here and also parsed to locale
.
Not sent from jsettlers clients older than 2.0.00;
if null, should probably assume en_US
since older versions had all messages in english.
Bots always use a null
locale, see locale
javadoc for details.
wantsI18N
public boolean wantsI18N
SOCGameOptionGetInfos.hasTokenGetI18nDescs()
true.
Server can later check this flag to see if responses to various client request
messages should include localized strings.
Set this flag only if:
SOCGameOptionGetInfos
request with
msg.hasTokenGetI18nDescs()
c.getI18NLocale()
!= null
c.getVersion()
>= SOCStringManager.VERSION_FOR_I18N
;
this is already implied by the client sending a message with hasTokenGetI18nDescs
.
locale
private int currentCreatedGames
private int currentCreatedChannels
private java.lang.Object countFieldSync
private boolean sentGameList
SOCGameList.takeMonitor()
/ releaseMonitor.
public boolean checkedLocaleScenStrings
SOCServer.clientHasLocalizedStrs_gameScenarios(StringConnection)
,
storing the result in localeHasScenStrings
.
public boolean localeHasScenStrings
SOCServer.clientHasLocalizedStrs_gameScenarios(StringConnection)
,
and this client's locale is not null
and has at least some localized scenario strings
(see that method's javadoc for details).
checkedLocaleScenStrings
,
sentAllScenarioStrings
public boolean sentAllScenarioStrings
SOCScenario
s.
To reduce network traffic, those large strings aren't sent unless the client is creating a
new game and needs the scenario dropdown.
Also true if the client's locale doesn't have localized strings for scenarios, or if the client is too old (1.1.xx) to use i18n localization.
scenariosInfoSent
,
sentAllScenarioInfo
,
localeHasScenStrings
public boolean sentAllScenarioInfo
SOCScenario
info.
Like sentAllScenarioStrings
, scenario info messages aren't sent unless needed.
Also true if the client is too old (1.1.xx) to use scenarios.
scenariosInfoSent
,
sentAllScenarioStrings
public static final java.lang.String SENT_SCEN_STRINGS
scenariosInfoSent
, value indicating that the client
was sent localized scenario strings (not all scenario info fields), or that the client
requested them and no localized strings were found for that scenario.
SENT_SCEN_INFO
,
Constant Field Valuespublic static final java.lang.String SENT_SCEN_INFO
scenariosInfoSent
, value indicating that the client
was sent all scenario info fields (not only localized scenario strings).
SENT_SCEN_STRINGS
,
Constant Field Valuespublic java.util.Map<java.lang.String,java.lang.String> scenariosInfoSent
SOCScenario
keynames for which we've
sent localized strings or all scenario info fields.
To reduce network traffic, those large strings aren't sent unless
the client is joining a game with a scenario, or has requested them.
For any scenario's keyname here, the value will be either SENT_SCEN_STRINGS
or SENT_SCEN_INFO
.
If a scenario's key isn't contained in this map, nothing has been sent about it
unless the sentAllScenarioStrings
flag is set.
Null if sentAllScenarioStrings
or if client hasn't requested any
or joined any game that has a scenario.
SOCGameOption
strings are also localized, but aren't tracked
the same way because game option strings are all sent when the client connects.
public boolean isRobot
public boolean isBuiltInRobot
robot3rdPartyBrainClass
,
SOCImARobot
public java.lang.String robot3rdPartyBrainClass
isBuiltInRobot
, this field is null,
not SOCImARobot.RBCLASS_BUILTIN
.
public long disconnectLastPingMillis
System.currentTimeMillis()
.
Value is 0 otherwise.
Only client versions 1.1.08 and higher respond to
the SOCMessage.SERVERPING
message.
private SOCClientData.SOCCDCliVersionTask cliVersionTask
Constructor Detail |
---|
public SOCClientData()
Method Detail |
---|
public void wonGame()
public void lostGame()
public void createdGame()
public void createdChannel()
public void deletedGame()
public void deletedChannel()
public int getWins()
public int getLosses()
public int getCurrentCreatedGames()
public int getcurrentCreatedChannels()
public void copyClientPlayerStats(SOCClientData source)
getWins()
, getLosses()
).
source
- Copy from herepublic boolean hasSentGameList()
SOCGameList.takeMonitor()
/ releaseMonitor.
public void setSentGameList()
SOCGameList.takeMonitor()
/ releaseMonitor.
public void setVersionTimer(SOCServer sr, StringConnection con)
SOCServer.CLI_VERSION_TIMER_FIRE_MS
milliseconds.
sr
- Our SOCServercon
- Connection for this timer / this clientdatapublic void clearVersionTimer()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |