|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.lang.Thread soc.server.genericServer.Server soc.server.SOCServer
public class SOCServer
A server for Settlers of Catan
For server command line options, use the --help option.
If the database is used (see SOCDBHelper
), users can
be set up with a username & password in that database to log in and play.
Users without accounts can connect by leaving the password blank,
as long as they aren't using a nickname which has a password in the database.
There's a database setup script parameter SOCDBHelper.PROP_JSETTLERS_DB_SCRIPT_SETUP
.
If the setup script is ran, the server exits afterward, so that the
script won't be part of the command line for normal server operation.
Network traffic:
The first message over the connection is the client's version
and the second is the server's response:
Either SOCRejectConnection
, or the lists of
channels and games (SOCChannels
, SOCGames
).
SOCMessage
for details of the client/server protocol.
Server
for details of the server threading and processing.
getConnection(plName)
.
connection.getData()
.
SOCClientData
)
connection.getAppData()
.
messageToGame(String, SOCMessage)
and related methods.
The server supports several debug commands when enabled
, and
when sent as chat messages by a user named "debug".
(Or, by the only user in a practice game.)
See processDebugCommand(StringConnection, String, String, String)
and handleGAMETEXTMSG(StringConnection, SOCGameTextMsg)
for details.
The version check timer is set in SOCClientData.setVersionTimer(SOCServer, StringConnection)
.
Before 1.1.06, the server's response was first message,
and client version was then sent in reply to server's version.
Java properties (starting with "jsettlers.") were added in 1.1.09, with constant names
starting with PROP_JSETTLERS_, and listed in PROPS_LIST
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class soc.server.genericServer.Server |
---|
Server.ConnExcepDelayedPrintTask, Server.NetStringServerSocket |
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
private boolean |
acctsNotOpenRegButNoUsers
Server internal flag to indicate that user accounts are active, and authentication is required to create accounts, and there aren't any accounts in the database yet. |
private static java.lang.String |
ADMIN_COMMANDS_HEADING
Heading to show above any admin commands the user is authorized to run. |
static java.lang.String[] |
ADMIN_USER_COMMANDS_HELP
List and description of user-admin commands. |
private boolean |
allowDebugUser
Is a debug user allowed to run commands listed in DEBUG_COMMANDS_HELP ?
Default is false. |
private static int |
AUTH_OR_REJECT__FAILED
authOrRejectClientUser(....)
result: Failed authentication, failed name validation, or name is already logged in and that
connection hasn't timed out yet |
private static int |
AUTH_OR_REJECT__OK
authOrRejectClientUser(....)
result: Authentication succeeded |
private static int |
AUTH_OR_REJECT__TAKING_OVER
authOrRejectClientUser(....)
result: Authentication succeeded, is taking over another connection |
protected SOCChannelList |
channelList
list of chat channels |
static int |
CLI_VERSION_ASSUMED_GUESS
If client never tells us their version, assume they are version 1.0.0 (1000). |
static int |
CLI_VERSION_MIN
Minimum required client version, to connect and play a game. |
static java.lang.String |
CLI_VERSION_MIN_DISPLAY
Minimum required client version, in "display" form, like "1.0.00". |
static int |
CLI_VERSION_TIMER_FIRE_MS
Client version is guessed after this many milliseconds (1200) if the client hasn't yet sent it to us. |
static int |
CLIENT_MAX_CREATE_CHANNELS
Maximum number of chat channels that a client can create at the same time (default 2). |
static int |
CLIENT_MAX_CREATE_GAMES
Maximum number of games that a client can create at the same time (default 5). |
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> |
clientPastVersionStats
Client version count stats since startup (includes bots). |
private java.lang.Object |
countFieldSync
Synchronization for numberOfGamesFinished writes. |
(package private) java.lang.String |
databasePassword
|
private java.util.Set<java.lang.String> |
databaseUserAdmins
User admins whitelist, from PROP_JSETTLERS_ACCOUNTS_ADMINS , or null if disabled. |
(package private) java.lang.String |
databaseUserName
|
static java.lang.String[] |
DEBUG_COMMANDS_HELP
List and description of debug/admin commands. |
private SOCServerFeatures |
features
Active optional server features, if any; see SOCServerFeatures constants for currently defined features. |
static int |
GAME_NAME_MAX_LENGTH
Maximum permitted game name length, default 30 characters. |
static int |
GAME_TIME_EXPIRE_ADDTIME_MINUTES
Amount of time to add (30 minutes) when the *ADDTIME* command is used by a player. |
static int |
GAME_TIME_EXPIRE_CHECK_MINUTES
Sleep time (minutes) between checks for expired games in SOCGameTimeoutChecker.run() . |
static int |
GAME_TIME_EXPIRE_WARN_MINUTES
If game will expire in this or fewer minutes, warn the players. |
protected SOCGameListAtServer |
gameList
list of soc games |
(package private) SOCGameTimeoutChecker |
gameTimeoutChecker
game timeout checker |
static java.lang.String[] |
GENERAL_COMMANDS_HELP
List and description of general commands that any game member can run. |
private static char[] |
GENERATEROBOTCOOKIE_HEX
The 16 hex characters to use in generateRobotCookie() . |
private SOCGameHandler |
handler
Game type handler, currently shared by all game instances. |
static boolean |
hasSetGameOptions
Did the properties or command line include --option / -o to set game option values?
Checked in constructors for possible stderr option-values printout. |
private static boolean |
hasStartupPrintAndExit
Did the command line include an option that prints some information (like --help or --version) and should exit, instead of starting the server? Set in parseCmdline_DashedArgs(String[]) . |
private boolean |
hasUtilityModeProp
True if props contains a property which is used to run the server in Utility Mode
instead of Server Mode. |
private static java.lang.String |
i18n_gameopt_PL_desc
Description string for SOCGameOption "PL" hardcoded into the SOCGameOption class,
from SOCGameOption.getOption("PL", false) . |
(package private) static java.lang.String |
i18n_scenario_SC_WOND_desc
Short description string for SOCScenario "SC_WOND" hardcoded into the SOCScenario class. |
protected int |
maxConnections
Maximum number of connections allowed. |
static java.lang.String |
MSG_NICKNAME_ALREADY_IN_USE
Status Message to send, nickname already logged into the system |
static java.lang.String |
MSG_NICKNAME_ALREADY_IN_USE_NEWER_VERSION_P1
Part 1 of Status Message to send, nickname already logged into the system with a newer client version. |
static java.lang.String |
MSG_NICKNAME_ALREADY_IN_USE_NEWER_VERSION_P2
Part 2 of Status Message to send, nickname already logged into the system with a newer client version. |
static java.lang.String |
MSG_NICKNAME_ALREADY_IN_USE_WAIT_TRY_AGAIN
Status Message to send, nickname already logged into the system. |
static int |
NICKNAME_TAKEOVER_SECONDS_DIFFERENT_IP
Number of seconds before a connection is considered disconnected, and its nickname can be "taken over" by a new connection from a different IP. |
static int |
NICKNAME_TAKEOVER_SECONDS_SAME_IP
Number of seconds before a connection is considered disconnected, and its nickname can be "taken over" by a new connection from the same IP. |
static int |
NICKNAME_TAKEOVER_SECONDS_SAME_PASSWORD
Number of seconds before a connection is considered disconnected, and its nickname can be "taken over" by a new connection with the right password. |
protected int |
numberOfGamesFinished
The total number of games finished: Game state became SOCGame.OVER or higher
from an earlier/lower state. |
protected int |
numberOfGamesStarted
The total number of games that have been started: GameHandler.startGame(SOCGame) has been called
and game play has begun. |
protected int |
numberOfUsers
total number of users |
private int |
numRobotOnlyGamesRemaining
Number of robot-only games not yet started (optional feature). |
static int |
PLAYER_NAME_MAX_LENGTH
Maximum permitted player name length, default 20 characters. |
static java.lang.String |
PRACTICE_STRINGPORT
For local practice games (pipes, not TCP), the name of the pipe. |
static boolean |
printedUsageAlready
Track whether we've already called printUsage(boolean) . |
static java.lang.String |
PROP_JSETTLERS_ACCOUNTS_ADMINS
Property jsettlers.accounts.admins to restrict which usernames can create accounts. |
static java.lang.String |
PROP_JSETTLERS_ACCOUNTS_OPEN
Boolean property jsettlers.accounts.open to permit open registration. |
static java.lang.String |
PROP_JSETTLERS_ACCOUNTS_REQUIRED
Boolean property jsettlers.accounts.required to require that all players have user accounts. |
static java.lang.String |
PROP_JSETTLERS_ALLOW_DEBUG
Property jsettlers.allow.debug to permit debug commands over TCP. |
static java.lang.String |
PROP_JSETTLERS_BOTS_BOTGAMES_TOTAL
Property jsettlers.bots.botgames.total will start robot-only games, a few at a time, until this many have been played. |
static java.lang.String |
PROP_JSETTLERS_BOTS_COOKIE
String property jsettlers.bots.cookie to specify the robot connect cookie. |
static java.lang.String |
PROP_JSETTLERS_BOTS_SHOWCOOKIE
Boolean property jsettlers.bots.showcookie to print the robot connect cookie to System.err during server startup. |
static java.lang.String |
PROP_JSETTLERS_CLI_MAXCREATECHANNELS
Property jsettlers.client.maxcreatechannels to limit the amount of chat channels that a client can create at once. |
static java.lang.String |
PROP_JSETTLERS_CLI_MAXCREATEGAMES
Property jsettlers.client.maxcreategames to limit the amount of games that a client can create at once. |
static java.lang.String |
PROP_JSETTLERS_CONNECTIONS
Property jsettlers.connections to specify the maximum number of connections allowed. |
static java.lang.String |
PROP_JSETTLERS_GAMEOPT_PREFIX
Property prefix jsettlers.gameopt. to specify game option defaults in a server properties file. |
static java.lang.String |
PROP_JSETTLERS_PORT
Property jsettlers.port to specify the port the server listens on. |
static java.lang.String |
PROP_JSETTLERS_STARTROBOTS
Property jsettlers.startrobots to start some robots when the server starts. |
private java.util.Properties |
props
Properties for the server, or empty if that constructor wasn't used. |
static java.lang.String[] |
PROPS_LIST
List and descriptions of all available JSettlers properties ,
such as PROP_JSETTLERS_PORT and SOCDBHelper.PROP_JSETTLERS_DB_URL . |
private java.util.Random |
rand
So we can get random numbers. |
static int |
ROBOT_FORCE_ENDTURN_SECONDS
Force robot to end their turn after this many seconds of inactivity. |
static SOCRobotParameters |
ROBOT_PARAMS_DEFAULT
Robot default parameters; copied for each newly connecting robot. |
static SOCRobotParameters |
ROBOT_PARAMS_SMARTER
Smarter robot default parameters. |
private java.lang.String |
robotCookie
Randomly generated cookie string required for robot clients to connect and identify as bots using SOCImARobot . |
protected java.util.Hashtable<java.lang.String,java.util.Vector<SOCReplaceRequest>> |
robotDismissRequests
table of requestst for robots to leave games |
protected java.util.Hashtable<java.lang.String,java.util.Vector<StringConnection>> |
robotJoinRequests
table of requests for robots to join games |
protected java.util.Vector<StringConnection> |
robots
A list of robot StringConnection s connected to this server. |
static java.lang.String |
SERVERNAME
Name used when sending messages from the server. |
(package private) SOCServerRobotPinger |
serverRobotPinger
server robot pinger |
static int |
SOC_MAXCONN_DEFAULT
Default maximum number of connected clients (30; maxConnections field). |
static int |
SOC_PORT_DEFAULT
Default tcp port number 8880 to listen, and for client to connect to remote server. |
static java.lang.String |
SOC_SERVER_PROPS_FILENAME
Filename "jsserver.properties" for the optional server startup properties file. |
static int |
SOC_STARTROBOTS_DEFAULT
Default number of bots to start (7; PROP_JSETTLERS_STARTROBOTS property). |
private java.lang.String |
srvShutPassword
JM temp - generated password to allow clean server shutdown. |
private long |
srvShutPasswordExpire
JM temp - expiration of srvShutPassword . |
protected long |
startTime
the time that this server was started |
private static java.io.BufferedReader |
sysInBuffered
Buffered System.in for readPassword(String) ,
is null until first call to that method. |
private java.lang.String |
utilityModeMessage
If hasUtilityModeProp , an optional status message to print before exiting, or null . |
Fields inherited from class soc.server.genericServer.Server |
---|
CLI_CONN_PRINT_TIMER_FIRE_MS, CLI_DISCON_PRINT_TIMER_FIRE_MS, CLI_VERSION_SET_CONSIS_CHECK_MINUTES, CLI_VERSION_SET_CONSIS_CHECK_QUICK_COUNT, cliConnDisconPrintsPending, conns, error, inQueue, numberCurrentConnections, numberOfConnections, port, strSocketName, unnamedConns, utilTimer |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
SOCServer(int p,
int mc,
java.lang.String databaseUserName,
java.lang.String databasePassword)
Create a Settlers of Catan server listening on TCP port p . |
|
SOCServer(int p,
java.util.Properties props)
Create a Settlers of Catan server listening on TCP port p . |
|
SOCServer(java.lang.String s,
int mc,
java.lang.String databaseUserName,
java.lang.String databasePassword)
Create a Settlers of Catan server listening on local stringport s . |
Method Summary | |
---|---|
private boolean |
authenticateUser(StringConnection c,
java.lang.String userName,
java.lang.String password)
authenticate the user: see if the user is in the db, if so then check the password. |
private int |
authOrRejectClientUser(StringConnection c,
java.lang.String msgUser,
java.lang.String msgPass,
int cliVers,
boolean doNameConnection,
boolean allowTakeover)
Check that the username and password (if any) is okay: Length versus PLAYER_NAME_MAX_LENGTH , name
in use but not timed out versus takeover, etc. |
void |
checkForExpiredGames(long currentTimeMillis)
check for games that have expired and destroy them. |
void |
checkForExpiredTurns(long currentTimeMillis)
Check all games for robot turns that have expired, and end that turn, or stop waiting for non-current-player robot actions (discard picks, etc). |
private static java.lang.String |
checkNickname_getRetryText(int nameTimeout)
For a nickname that seems to be in use, build a text message with the time remaining before someone can attempt to take over that nickname. |
private static java.lang.String |
checkNickname_getVersionText(int needsVersion)
For a nickname that seems to be in use, build a text message with the minimum version number needed to take over that nickname. |
private int |
checkNickname(java.lang.String n,
StringConnection newc,
boolean withPassword)
Check if a nickname is okay, and, if they're already logged in, whether a new replacement connection can "take over" the existing one. |
static java.util.List<Triple> |
checkScenarioOpts(java.util.Map<?,?> opts,
boolean optsAreProps,
java.lang.String scName)
When a server's properties or command line contain a default scenario (game option "SC" ),
check that the scenario is known and that its game options don't conflict with any others specified
in the properties or command line. |
private static void |
clearBuffer(java.lang.StringBuilder sb)
Clear the contents of a StringBuffer by setting to ' ' each character in its current StringBuilder.length() . |
static boolean |
clientHasLocalizedStrs_gameScenarios(StringConnection c)
Does this client's locale have localized SOCScenario names and descriptions?
Checks these conditions:
c.scd.wantsI18N flag is set:
Has locale, new-enough version, has requested I18N strings (see that flag's javadocs). |
void |
connectToChannel(StringConnection c,
java.lang.String ch)
Adds a connection to a chat channel. |
boolean |
connectToGame(StringConnection c,
java.lang.String gaName,
java.util.Map<java.lang.String,SOCGameOption> gaOpts)
Adds a connection to a game, unless they're already a member. |
private SOCGame |
createGameAndBroadcast(StringConnection c,
java.lang.String gaName,
java.util.Map<java.lang.String,SOCGameOption> gaOpts,
int gVers,
boolean isBotsOnly,
boolean hasGameListMonitor)
Create a new game, and announce it with a broadcast. |
private void |
createOrJoinGameIfUserOK(StringConnection c,
java.lang.String msgUser,
java.lang.String msgPass,
java.lang.String gameName,
java.util.Map<java.lang.String,SOCGameOption> gameOpts)
Check username/password and create new game, or join game. |
private boolean |
debug_printPieceDiceNumbers_pl(SOCPlayer pl,
int roll,
SOCBoard board,
java.lang.String pieceType,
java.util.Enumeration<? extends SOCPlayingPiece> pe)
Temporary debugging; for 1 player. |
(package private) void |
debug_printPieceDiceNumbers(SOCGame ga,
java.lang.String message)
Temporary debugging; call when "no player gets anything" will be printed after a roll. |
protected void |
destroyChannel(java.lang.String ch)
Destroy a channel and then clean up related data, such as the owner's count of SOCClientData.getcurrentCreatedChannels() . |
void |
destroyGame(java.lang.String gm)
Destroy a game and clean up related data, such as the owner's count of SOCClientData.getCurrentCreatedGames() . |
void |
destroyGameAndBroadcast(java.lang.String gaName,
java.lang.String descForStackTrace)
Destroy a game and then broadcast its deletion, including lock handling. |
(package private) void |
gameOverIncrGamesFinishedCount()
Increment the "number of games finished" server-statistics field. |
private java.lang.String |
generateRobotCookie()
Generate and return a string to use for robotCookie . |
private static boolean |
getConfigBoolProperty(java.util.Properties props,
java.lang.String pName,
boolean pDefault)
Get and parse a boolean config property, or use its default instead. |
private static int |
getConfigIntProperty(java.util.Properties props,
java.lang.String pName,
int pDefault)
Get and parse an integer config property, or use its default instead. |
(package private) StringConnection |
getConnection(java.lang.String connKey)
Given a connection's key, return the connected client. |
SOCGame |
getGame(java.lang.String gaName)
Given a game name on this server, return its game object. |
java.util.Collection<java.lang.String> |
getGameNames()
Used when SOCPlayerClient is also hosting games. |
java.util.Map<java.lang.String,SOCGameOption> |
getGameOptions(java.lang.String gm)
Given a game name on this server, return its game options. |
int |
getGameState(java.lang.String gm)
Given a game name on this server, return its state. |
java.lang.String |
getUtilityModeMessage()
If hasUtilityModeProperty() , get the optional status message to print before exiting. |
private void |
handleAUTHREQUEST(StringConnection c,
SOCAuthRequest mes)
Handle the optional "authentication request" message. |
private void |
handleCHANGEFACE(StringConnection c,
SOCChangeFace mes)
handle "change face" message. |
private void |
handleCREATEACCOUNT(StringConnection c,
SOCCreateAccount mes)
handle "create account" message |
private void |
handleGAMEOPTIONGETDEFAULTS(StringConnection c,
SOCGameOptionGetDefaults mes)
process the "game option get defaults" message. |
private void |
handleGAMEOPTIONGETINFOS(StringConnection c,
SOCGameOptionGetInfos mes)
process the "game option get infos" message; reply with the info, with one GAMEOPTIONINFO message per option keyname. |
private void |
handleGAMETEXTMSG(StringConnection c,
SOCGameTextMsg gameTextMsgMes)
Handle game text messages, including debug commands. |
private void |
handleIMAROBOT(StringConnection c,
SOCImARobot mes)
Handle the "I'm a robot" message. |
private void |
handleJOIN(StringConnection c,
SOCJoin mes)
Handle the "join a channel" message. |
private void |
handleJOINGAME(StringConnection c,
SOCJoinGame mes)
Handle the "join a game" message: Join or create a game. |
private void |
handleLEAVE(StringConnection c,
SOCLeave mes)
Handle the "leave a channel" message |
private void |
handleLEAVEGAME_maybeGameReset_oldRobot(java.lang.String gaName)
Handle an unattached robot saying it is leaving the game, from handleLEAVEGAME(StringConnection, SOCLeaveGame) . |
private void |
handleLEAVEGAME_member(StringConnection c,
java.lang.String gaName)
Handle a member leaving the game, from handleLEAVEGAME(StringConnection, SOCLeaveGame) . |
private void |
handleLEAVEGAME(StringConnection c,
SOCLeaveGame mes)
Handle the "leave game" message |
private void |
handleLOCALIZEDSTRINGS(StringConnection c,
SOCLocalizedStrings mes)
Handle client request for localized i18n strings for game items. |
private void |
handleNEWGAMEWITHOPTIONSREQUEST(StringConnection c,
SOCNewGameWithOptionsRequest mes)
process the "new game with options request" message. |
private void |
handleRESETBOARDREQUEST(StringConnection c,
SOCResetBoardRequest mes)
handle "reset-board request" message. |
private void |
handleRESETBOARDVOTE(StringConnection c,
SOCResetBoardVote mes)
handle message of player's vote for a "reset-board" request. |
private void |
handleSCENARIOINFO(StringConnection c,
SOCScenarioInfo mes)
Process client request for updated SOCScenario info. |
private void |
handleSERVERPING(StringConnection c,
SOCServerPing mes)
Handle the client's echo of a SOCMessage.SERVERPING . |
private void |
handleSETSEATLOCK(StringConnection c,
SOCSetSeatLock mes)
handle "set seat lock" message. |
private void |
handleSITDOWN(StringConnection c,
SOCSitDown mes)
handle "sit down" message |
private void |
handleSTARTGAME(StringConnection c,
SOCStartGame mes,
int botsOnly_maxBots)
handle "start game" message. |
private void |
handleVERSION(StringConnection c,
SOCVersion mes)
Handle the "version" message, client's version report. |
boolean |
hasUtilityModeProperty()
True if the server was constructed with a property or command line argument which is used to run the server in Utility Mode instead of Server Mode. |
private void |
impl_messageToGameKeyedSpecial(SOCGame ga,
boolean takeMon,
java.util.List<StringConnection> members,
StringConnection ex,
boolean fmtSpecial,
java.lang.String key,
java.lang.Object... params)
Implement messageToGameKeyedSpecial and messageToGameKeyedSpecialExcept . |
private static boolean |
init_checkScenarioOpts(java.util.Map<?,?> opts,
boolean optsAreProps,
java.lang.String srcDesc,
java.lang.String scName,
java.lang.String scNameSrcDesc)
During startup, call checkScenarioOpts(Map, boolean, String) and print any warnings it returns
to System.err . |
private static void |
init_propsSetGameopts(java.util.Properties pr)
Set game option defaults from any jsettlers.gameopt.* server properties found. |
private void |
init_resetUserPassword(java.lang.String uname)
If command line contains --pw-reset=username ,
prompt for and change that user's password. |
private void |
initSocServer(java.lang.String databaseUserName,
java.lang.String databasePassword,
java.util.Properties props)
Common init for all constructors. |
private boolean |
isUserDBUserAdmin(java.lang.String uname,
boolean requireList)
Is this username on the databaseUserAdmins whitelist, if that whitelist is being used? |
private void |
joinGame(SOCGame gameData,
StringConnection c,
boolean isReset,
boolean isTakingOver)
Client has been approved to join game; send the entire state of the game to client. |
void |
leaveAllChannels(StringConnection c)
Connection c is leaving the server; remove from all channels it was in. |
void |
leaveAllGames(StringConnection c)
Connection c is leaving the server; remove from all games it was in. |
boolean |
leaveChannel(StringConnection c,
java.lang.String ch,
boolean destroyIfEmpty,
boolean channelListLock)
Connection c leaves the channel ch . |
void |
leaveConnection(StringConnection c)
things to do when the connection c leaves |
boolean |
leaveGame(StringConnection c,
java.lang.String gm,
boolean destroyIfEmpty,
boolean gameListLock)
the connection c leaves the game gm. |
static java.util.List<java.lang.String> |
localizeGameScenarios(java.util.Locale loc,
java.util.Collection<java.lang.String> scKeys,
boolean checkUnknowns_skipFirst,
SOCClientData scd)
Get localized strings for known SOCScenario s. |
static java.util.Map<java.lang.String,SOCGameOption> |
localizeKnownOptions(java.util.Locale loc,
boolean updateStaticKnownOpts)
Given a StringManager (for a client's locale), return all known game options, localizing the descriptive names if available. |
static void |
main(java.lang.String[] args)
Starting the server from the command line |
void |
messageToChannel(java.lang.String ch,
SOCMessage mes)
Send a message to the given channel |
void |
messageToChannelWithMon(java.lang.String ch,
SOCMessage mes)
Send a message to the given channel WARNING: MUST HAVE THE gameList.takeMonitorForChannel(ch) before calling this method |
void |
messageToGame(java.lang.String ga,
SOCMessage mes)
Send a message to the given game. |
void |
messageToGame(java.lang.String ga,
java.lang.String txt)
Send a server text message to the given game. |
void |
messageToGameExcept(java.lang.String gn,
StringConnection ex,
SOCMessage mes,
boolean takeMon)
Send a message to all the connections in a game excluding one. |
void |
messageToGameExcept(java.lang.String gn,
StringConnection ex,
java.lang.String txt,
boolean takeMon)
Send a server text message to all the connections in a game excluding one. |
void |
messageToGameExcept(java.lang.String gn,
java.util.Vector<StringConnection> ex,
SOCMessage mes,
boolean takeMon)
Send a message to all the connections in a game excluding some. |
void |
messageToGameForVersions(SOCGame ga,
int vmin,
int vmax,
SOCMessage mes,
boolean takeMon)
Send a message to all the connections in a game in a certain version range. |
void |
messageToGameForVersionsExcept(SOCGame ga,
int vmin,
int vmax,
StringConnection ex,
SOCMessage mes,
boolean takeMon)
Send a message to all the connections in a game in a certain version range, excluding one. |
void |
messageToGameKeyed(SOCGame ga,
boolean takeMon,
java.lang.String key)
Send a localized SOCGameServerText game text message to a game. |
void |
messageToGameKeyed(SOCGame ga,
boolean takeMon,
java.lang.String key,
java.lang.Object... params)
Send a localized SOCGameServerText game text message (with parameters) to a game. |
void |
messageToGameKeyedSpecial(SOCGame ga,
boolean takeMon,
java.lang.String key,
java.lang.Object... params)
Send a localized SOCGameServerText game text message (with parameters) to a game,
optionally with special formatting like {0,rsrcs}, optionally excluding one connection. |
void |
messageToGameKeyedSpecialExcept(SOCGame ga,
boolean takeMon,
java.util.List<StringConnection> ex,
java.lang.String key,
java.lang.Object... params)
Send a localized SOCGameServerText game text message (with parameters) to a game,
optionally with special formatting like {0,rsrcs}, optionally excluding some connections. |
void |
messageToGameKeyedSpecialExcept(SOCGame ga,
boolean takeMon,
StringConnection ex,
java.lang.String key,
java.lang.Object... params)
Send a localized SOCGameServerText game text message (with parameters) to a game,
optionally with special formatting like {0,rsrcs}, optionally excluding one connection. |
void |
messageToGameKeyedType(SOCGame ga,
SOCKeyedMessage msg,
boolean takeMon)
Send a game a message containing data fields and also a text field to be localized. |
void |
messageToGameUrgent(java.lang.String ga,
java.lang.String mes)
Send an urgent SOCGameTextMsg to the given game. |
void |
messageToGameWithMon(java.lang.String ga,
SOCMessage mes)
Send a message to the given game. |
void |
messageToPlayer(StringConnection c,
SOCMessage mes)
Send a message to a player and record it |
void |
messageToPlayer(StringConnection c,
java.lang.String ga,
java.lang.String txt)
Send a SOCGameServerText or SOCGameTextMsg game text message to a player. |
void |
messageToPlayerKeyed(StringConnection c,
java.lang.String gaName,
java.lang.String key)
Send a localized SOCGameServerText game text message to a player. |
void |
messageToPlayerKeyed(StringConnection c,
java.lang.String gaName,
java.lang.String key,
java.lang.Object... args)
Send a localized SOCGameServerText game text message with arguments to a player. |
void |
messageToPlayerKeyedSpecial(StringConnection c,
SOCGame ga,
java.lang.String key,
java.lang.Object... args)
Send a localized SOCGameServerText game text message with arguments to a player,
with special formatting like {0,rsrcs}. |
private void |
nameConnection(StringConnection c,
boolean isReplacing)
Name a current connection to the system, which may replace an older connection. |
boolean |
newConnection1(StringConnection c)
Things to do when a new connection comes. |
protected void |
newConnection2(StringConnection c)
Send welcome messages (server version and features, and the lists of channels and games ( SOCChannels , SOCGames )) when a new
connection comes, part 2 - c has been accepted and added to a connection list. |
static java.util.Properties |
parseCmdline_DashedArgs(java.lang.String[] args)
Quick-and-dirty parsing of command-line arguments with dashes. |
static SOCGameOption |
parseCmdline_GameOption(SOCGameOption op,
java.lang.String optRaw,
java.util.HashMap<java.lang.String,java.lang.String> optsAlreadySet)
Quick-and-dirty command line parsing of a game option. |
private void |
printAuditMessage(java.lang.String req,
java.lang.String msg,
java.lang.String obj,
java.util.Date at,
java.lang.String reqHost)
Print a security-action audit message to System.out in a standard format. |
static void |
printGameOptions()
Print out the list of possible game options, and current values. |
static void |
printUsage(boolean longFormat)
Print command line parameter information, including options ("--" / "-"). |
void |
processCommand(java.lang.String s,
StringConnection c)
Treat the incoming messages. |
private void |
processDebugCommand_gameStats(StringConnection c,
java.lang.String gaName,
SOCGame gameData,
boolean isCheckTime)
Print time-remaining and other game stats. |
private void |
processDebugCommand_who(StringConnection c,
SOCGame ga,
java.lang.String cmdText)
Process unprivileged command *WHO* to show members of current game,
or privileged *WHO* gameName|all|* to show all connected clients or some other game's members. |
boolean |
processDebugCommand(StringConnection debugCli,
java.lang.String ga,
java.lang.String dcmd,
java.lang.String dcmdU)
Process a debug command, sent by the "debug" client/player. |
boolean |
processFirstCommand(java.lang.String str,
StringConnection con)
Callback to process the client's first message command specially. |
private static java.lang.StringBuilder |
readPassword(java.lang.String prompt)
Read a password from the console; currently used for password reset. |
private void |
readyGameAskRobotsJoin(SOCGame ga,
StringConnection[] robotSeats,
int maxBots)
Fill all the unlocked empty seats with robots, by asking them to join. |
protected void |
recordGameEvent(java.lang.String gameName,
java.lang.String event)
record events that happen during the game |
private void |
resetBoardAndNotify_finish(SOCGameBoardReset reBoard,
SOCGame reGame)
Complete steps 3 - n of the board-reset process outlined in resetBoardAndNotify(String, int) ,
after any robots have left the old game. |
private void |
resetBoardAndNotify(java.lang.String gaName,
int requestingPlayer)
Reset the board, to a copy with same players but new layout. |
(package private) void |
resetBoardVoteNotifyOne(SOCGame ga,
int pn,
java.lang.String plName,
boolean vyes)
"Reset-board" request: Register one player's vote, and let game members know. |
(package private) int[] |
robotShuffleForJoin()
shuffle the indexes to distribute load among robots |
void |
sendGameList(StringConnection c,
int prevVers)
Send the entire list of games to this client; this is sent once per connecting client. |
(package private) void |
sendGameScenarioInfo(java.lang.String scKey,
SOCScenario sc,
StringConnection c,
boolean stringsOnly)
If needed, send this scenario's updated info and i18n localized short/long description strings to the client. |
void |
serverUp()
Callback to take care of things when server comes up, after the server socket is bound and listening, in the main thread. |
(package private) boolean |
setClientVersSendGamesOrReject(StringConnection c,
int cvers,
java.lang.String clocale,
boolean isKnown)
Set client's version and locale, and check against minimum required version CLI_VERSION_MIN . |
boolean |
setupLocalRobots(int numFast,
int numSmart)
Set up some robot opponents, running in our JVM for operator convenience. |
private void |
sitDown(SOCGame ga,
StringConnection c,
int pn,
boolean robot,
boolean isReset)
This player is sitting down at the game. |
private void |
startRobotOnlyGames(boolean hasGameListMonitor)
Start a few robot-only games if numRobotOnlyGamesRemaining > 0. |
void |
stopServer()
The server is being cleanly stopped. |
void |
stopServer(java.lang.String stopMsg)
The server is being cleanly stopped. |
protected void |
storeGameScores(SOCGame ga)
Save game stats in the database. |
Methods inherited from class soc.server.genericServer.Server |
---|
addConnection, broadcast, broadcastToVers, clientVersionAdd, clientVersionRem, getConnection, getConnections, getCurrentConnectionCount, getLocalSocketName, getMaxConnectedCliVersion, getMinConnectedCliVersion, getNamedConnectionCount, getPort, isCliVersionConnected, isUp, nameConnection, removeConnection, removeConnectionCleanup, run, serverDown, treat |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int SOC_PORT_DEFAULT
8880 is the default SOCPlayerClient port since jsettlers 1.0.4, per cvs history.
public static final int SOC_STARTROBOTS_DEFAULT
PROP_JSETTLERS_STARTROBOTS
property).
public static final int SOC_MAXCONN_DEFAULT
maxConnections
field).
Always at least 20 more than SOC_STARTROBOTS_DEFAULT
.
public static final java.lang.String SOC_SERVER_PROPS_FILENAME
"jsserver.properties"
for the optional server startup properties file.
public static final java.lang.String PROP_JSETTLERS_PORT
public static final java.lang.String PROP_JSETTLERS_CONNECTIONS
public static final java.lang.String PROP_JSETTLERS_BOTS_COOKIE
SOCMessage.isSingleLineAndSafe(String)
:
Must not contain the '|'
or ','
characters.
PROP_JSETTLERS_BOTS_SHOWCOOKIE
,
Constant Field Valuespublic static final java.lang.String PROP_JSETTLERS_BOTS_SHOWCOOKIE
robot connect cookie
to System.err during server startup.
(The default is N, the cookie is not printed.)Format is:
Robot cookie: 03883269284ee140cb907ea203846333
public static final java.lang.String PROP_JSETTLERS_BOTS_BOTGAMES_TOTAL
If this property's value != 0, a robots-only game can be started with the *STARTBOTGAME* debug command. This can be used to test the bots with any given combination of game options and scenarios. To permit starting such games without also starting any at server startup, use a value less than 0.
public static final java.lang.String PROP_JSETTLERS_STARTROBOTS
SOC_STARTROBOTS_DEFAULT
.)
30% will be "smart" robots, the other 70% will be "fast" robots.
Remember that robots count against the max connections
limit.
Before v1.1.19 the default was 0, no robots were started by default.
PROP_JSETTLERS_BOTS_BOTGAMES_TOTAL
,
Constant Field Valuespublic static final java.lang.String PROP_JSETTLERS_ACCOUNTS_OPEN
jsettlers.accounts.open
to permit open registration.
If this property is Y, anyone can create their own user accounts.
Otherwise only existing users can create new accounts after the first account.
The default is N in version 1.1.19 and newer; previously was Y by default.
To require that all players have accounts in the database, see PROP_JSETTLERS_ACCOUNTS_REQUIRED
.
To restrict which users can create accounts, see PROP_JSETTLERS_ACCOUNTS_ADMINS
.
If this field is Y when the server is initialized, the server calls
features.add
(SOCServerFeatures.FEAT_OPEN_REG
).
public static final java.lang.String PROP_JSETTLERS_ACCOUNTS_REQUIRED
jsettlers.accounts.required
to require that all players have user accounts.
If this property is Y, a jdbc database is required and all users must have an account and password
in the database. If a client tries to join or create a game or channel without providing a password,
they will be sent SOCStatusMessage.SV_PW_REQUIRED
.
This property implies SOCServerFeatures.FEAT_ACCTS
.
The default is N.
If PROP_JSETTLERS_ACCOUNTS_OPEN
is used, anyone can create their own account (Open Registration).
Otherwise see PROP_JSETTLERS_ACCOUNTS_ADMINS
for the list of user admin accounts.
public static final java.lang.String PROP_JSETTLERS_ACCOUNTS_ADMINS
jsettlers.accounts.admins
to restrict which usernames can create accounts.
If this property is set, it is a comma-separated list of usernames (nicknames), and
a user must authenticate and be on this whitelist to create user accounts.
If any other user requests account creation, the server will reply with
SOCStatusMessage.SV_ACCT_NOT_CREATED_DENIED
.
The server doesn't require or check at startup that the named accounts all already exist, this is just a list of names.
This property can't be set at the same time as PROP_JSETTLERS_ACCOUNTS_OPEN
,
they ask for opposing security policies.
public static final java.lang.String PROP_JSETTLERS_ALLOW_DEBUG
public static final java.lang.String PROP_JSETTLERS_CLI_MAXCREATEGAMES
CLIENT_MAX_CREATE_GAMES
,
Constant Field Valuespublic static final java.lang.String PROP_JSETTLERS_CLI_MAXCREATECHANNELS
CLIENT_MAX_CREATE_CHANNELS
,
SOCServerFeatures.FEAT_CHANNELS
,
Constant Field Valuespublic static final java.lang.String PROP_JSETTLERS_GAMEOPT_PREFIX
jsettlers.gameopt.
to specify game option defaults in a server properties file.
Option names are case-insensitive past this prefix. Syntax for default value is the same as on the
command line, for example:
jsettlers.gameopt.RD=y jsettlers.gameopt.n7=t7
See parseCmdline_DashedArgs(String[])
for how game option properties are checked at startup.
public static final java.lang.String[] PROPS_LIST
properties
,
such as PROP_JSETTLERS_PORT
and SOCDBHelper.PROP_JSETTLERS_DB_URL
.
Each property name is followed in the array by a brief description:
[0] is a property, [1] is its description, [2] is the next property, etc.
(This was added in 1.1.13 for printUsage(boolean)
}.
public static final java.lang.String SERVERNAME
public static final int CLI_VERSION_MIN
Version.versionNumber()
.
Currently there is no enforced minimum (0000).
setClientVersSendGamesOrReject(StringConnection, int, String, boolean)
,
Constant Field Valuespublic static final java.lang.String CLI_VERSION_MIN_DISPLAY
setClientVersSendGamesOrReject(StringConnection, int, String, boolean)
,
Constant Field Valuespublic static final int CLI_VERSION_ASSUMED_GUESS
CLI_VERSION_TIMER_FIRE_MS
,
handleJOINGAME(StringConnection, SOCJoinGame)
,
Constant Field Valuespublic static final int CLI_VERSION_TIMER_FIRE_MS
CLI_VERSION_ASSUMED_GUESS
,
Constant Field Valuespublic static int GAME_TIME_EXPIRE_WARN_MINUTES
SOCGameTimeoutChecker.run()
.
The game expiry time is set at game creation in
SOCGameListAtServer.createGame(String, String, String, Map, GameHandler)
.
If you update this field, also update GAME_TIME_EXPIRE_CHECK_MINUTES
.
Before v2.0.00 this field was named GAME_EXPIRE_WARN_MINUTES
.
checkForExpiredGames(long)
,
SOCGameTimeoutChecker.run()
,
SOCGameListAtServer.GAME_TIME_EXPIRE_MINUTES
,
GAME_TIME_EXPIRE_ADDTIME_MINUTES
public static int GAME_TIME_EXPIRE_CHECK_MINUTES
SOCGameTimeoutChecker.run()
.
Default is 5 minutes. Must be at most half of GAME_TIME_EXPIRE_WARN_MINUTES
so the user has time to react after seeing the warning.
public static final int GAME_TIME_EXPIRE_ADDTIME_MINUTES
*ADDTIME*
command is used by a player.
GAME_TIME_EXPIRE_WARN_MINUTES
,
Constant Field Valuespublic static int ROBOT_FORCE_ENDTURN_SECONDS
checkForExpiredTurns(long)
public static int GAME_NAME_MAX_LENGTH
createOrJoinGameIfUserOK(StringConnection, String, String, String, Map)
public static int PLAYER_NAME_MAX_LENGTH
createOrJoinGameIfUserOK(StringConnection, String, String, String, Map)
public static int CLIENT_MAX_CREATE_GAMES
PROP_JSETTLERS_CLI_MAXCREATEGAMES
public static int CLIENT_MAX_CREATE_CHANNELS
If this field is nonzero when the server is initialized, the server calls
features.add
(SOCServerFeatures.FEAT_CHANNELS
).
If the field value is changed afterwards, that affects new clients joining the server
but does not clear FEAT_CHANNELS
from the features
list.
PROP_JSETTLERS_CLI_MAXCREATECHANNELS
public static java.lang.String PRACTICE_STRINGPORT
LocalStringConnection
private static final int AUTH_OR_REJECT__FAILED
authOrRejectClientUser(....)
result: Failed authentication, failed name validation, or name is already logged in and that
connection hasn't timed out yet
private static final int AUTH_OR_REJECT__OK
authOrRejectClientUser(....)
result: Authentication succeeded
private static final int AUTH_OR_REJECT__TAKING_OVER
authOrRejectClientUser(....)
result: Authentication succeeded, is taking over another connection
private java.util.Random rand
protected int maxConnections
PROP_JSETTLERS_CONNECTIONS
.
private boolean allowDebugUser
DEBUG_COMMANDS_HELP
?
Default is false. Set with PROP_JSETTLERS_ALLOW_DEBUG
.
Note that all practice games are debug mode, for ease of debugging;
to determine this, handleGAMETEXTMSG(StringConnection, SOCGameTextMsg)
checks if the
client is using LocalStringConnection
to talk to the server.
processDebugCommand(StringConnection, String, String, String)
private java.util.Properties props
features
.
SOCServer(int, Properties)
,
PROPS_LIST
,
getConfigBoolProperty(Properties, String, boolean)
,
getConfigIntProperty(Properties, String, int)
private boolean hasUtilityModeProp
props
contains a property which is used to run the server in Utility Mode
instead of Server Mode. In Utility Mode the server reads its properties, initializes its
database connection if any, and performs one task such as a password reset or table/index creation.
It won't listen on a TCP port or start other threads.
For a list of Utility Mode properties, see hasUtilityModeProperty()
.
utilityModeMessage
private java.lang.String utilityModeMessage
hasUtilityModeProp
, an optional status message to print before exiting, or null
.
private SOCServerFeatures features
SOCServerFeatures
constants for currently defined features.
Features are activated through the command line or props
.
private final SOCGameHandler handler
private boolean acctsNotOpenRegButNoUsers
SOCServerFeatures.FEAT_ACCTS
but not
SOCServerFeatures.FEAT_OPEN_REG
.) This flag is set at startup, instead of
querying SOCDBHelper.countUsers()
every time a client connects.
Used for signaling to SOCAccountClient
that it shouldn't ask for a
password when connecting to create the first account, by sending the client
SOCServerFeatures.FEAT_OPEN_REG
along with the actually active features.
The first successful account creation will clear this flag.
handleCREATEACCOUNT(StringConnection, SOCCreateAccount)
does call countUsers()
and requires auth if any account exists, even if this flag is set.
private java.lang.String srvShutPassword
srvShutPasswordExpire
.
private long srvShutPasswordExpire
srvShutPassword
.
private java.lang.String robotCookie
SOCImARobot
.
It isn't sent encrypted and is a weak "shared secret".
Generated in generateRobotCookie()
unless the server is given
PROP_JSETTLERS_BOTS_COOKIE
at startup, which can set it to
any string or to null
if the property is empty.
The value must pass SOCMessage.isSingleLineAndSafe(String)
:
Must not contain the '|'
or ','
characters.
protected java.util.Vector<StringConnection> robots
StringConnection
s connected to this server.
SOCLocalRobotClient.robotClients
public static SOCRobotParameters ROBOT_PARAMS_DEFAULT
handleIMAROBOT(StringConnection, soc.message.SOCImARobot)
,
SOCRobotDM
public static SOCRobotParameters ROBOT_PARAMS_SMARTER
ROBOT_PARAMS_DEFAULT
,
SOCRobotDM
private static boolean hasStartupPrintAndExit
parseCmdline_DashedArgs(String[])
.
public static boolean hasSetGameOptions
game option
values?
Checked in constructors for possible stderr option-values printout.
public static final java.lang.String MSG_NICKNAME_ALREADY_IN_USE
public static final java.lang.String MSG_NICKNAME_ALREADY_IN_USE_WAIT_TRY_AGAIN
MSG_NICKNAME_ALREADY_IN_USE
.
The "take over" option is used for reconnect when a client loses
connection, and server doesn't realize it.
A new connection can "take over" the name after a minute's timeout.
public static final java.lang.String MSG_NICKNAME_ALREADY_IN_USE_NEWER_VERSION_P1
MSG_NICKNAME_ALREADY_IN_USE_NEWER_VERSION_P2
,
Constant Field Valuespublic static final java.lang.String MSG_NICKNAME_ALREADY_IN_USE_NEWER_VERSION_P2
MSG_NICKNAME_ALREADY_IN_USE_NEWER_VERSION_P1
,
Constant Field Valuespublic static final int NICKNAME_TAKEOVER_SECONDS_SAME_PASSWORD
checkNickname(String, StringConnection, boolean)
,
Constant Field Valuespublic static final int NICKNAME_TAKEOVER_SECONDS_SAME_IP
checkNickname(String, StringConnection, boolean)
,
Constant Field Valuespublic static final int NICKNAME_TAKEOVER_SECONDS_DIFFERENT_IP
checkNickname(String, StringConnection, boolean)
,
Constant Field Valuesprotected SOCChannelList channelList
Instead of calling SOCChannelList.deleteChannel(String)
,
call destroyChannel(String)
to also clean up related server data.
protected SOCGameListAtServer gameList
protected java.util.Hashtable<java.lang.String,java.util.Vector<StringConnection>> robotJoinRequests
protected java.util.Hashtable<java.lang.String,java.util.Vector<SOCReplaceRequest>> robotDismissRequests
protected long startTime
protected int numberOfGamesStarted
GameHandler.startGame(SOCGame)
has been called
and game play has begun. Game state became SOCGame.READY
or higher from an earlier/lower state.
protected int numberOfGamesFinished
SOCGame.OVER
or higher
from an earlier/lower state. Incremented in gameOverIncrGamesFinishedCount()
.
Before v1.1.20 this was the number of games destroyed, and *STATS*
wouldn't reflect a newly finished game until all players had left that game.
private java.lang.Object countFieldSync
numberOfGamesFinished
writes.
protected int numberOfUsers
protected java.util.HashMap<java.lang.Integer,java.lang.Integer> clientPastVersionStats
handleVERSION(StringConnection, SOCVersion)
;
currently assumes single-threaded access to this map.
Key = version number, Value = client count.
private int numRobotOnlyGamesRemaining
PROP_JSETTLERS_BOTS_BOTGAMES_TOTAL
.
private static final java.lang.String i18n_gameopt_PL_desc
"PL"
hardcoded into the SOCGameOption class,
from SOCGameOption.getOption("PL", false)
.
Used for determining whether a client's i18n locale has localized option descriptions,
by comparing PL
's SOCGameOption.desc
to
StringManager.get("gameopt.PL"
).
String value is captured here as soon as SOCServer is referenced, in case SOCPlayerClient's
practice server will localize the descriptions used by SOCGameOption.getOption(String, boolean)
.
#i18n_scenario_SC_WOND_desc}
static final java.lang.String i18n_scenario_SC_WOND_desc
"SC_WOND"
hardcoded into the SOCScenario class.
Used for determining whether a client's i18n locale has localized scenario descriptions,
by comparing SC_WOND
's SOCScenario.desc
to
StringManager.get("gamescen.SC_WOND.n"
).
String value is captured here as soon as SOCServer is referenced, in case SOCPlayerClient's practice server will localize the scenario descriptions.
clientHasLocalizedStrs_gameScenarios(StringConnection)
,
i18n_gameopt_PL_desc
SOCServerRobotPinger serverRobotPinger
SOCGameTimeoutChecker gameTimeoutChecker
java.lang.String databaseUserName
java.lang.String databasePassword
private java.util.Set<java.lang.String> databaseUserAdmins
PROP_JSETTLERS_ACCOUNTS_ADMINS
, or null
if disabled.
If not null, only usernames on this list can create user accounts in
handleCREATEACCOUNT(StringConnection, SOCCreateAccount)
.
private static final char[] GENERATEROBOTCOOKIE_HEX
generateRobotCookie()
.
public static final java.lang.String[] GENERAL_COMMANDS_HELP
processDebugCommand(StringConnection, String, String, String)
}
when *HELP*
is requested.
ADMIN_USER_COMMANDS_HELP
,
DEBUG_COMMANDS_HELP
private static final java.lang.String ADMIN_COMMANDS_HEADING
ADMIN_USER_COMMANDS_HELP
for use when other admin types are added.
--- Admin Commands ---
public static final java.lang.String[] ADMIN_USER_COMMANDS_HELP
GENERAL_COMMANDS_HELP
and DEBUG_COMMANDS_HELP
, used by
processDebugCommand(StringConnection, String, String, String)
}
when *HELP*
is requested by a debug/admin user who passes
isUserDBUserAdmin(username, true)
.
Preceded by ADMIN_COMMANDS_HEADING
.
GENERAL_COMMANDS_HELP
,
DEBUG_COMMANDS_HELP
public static final java.lang.String[] DEBUG_COMMANDS_HELP
GENERAL_COMMANDS_HELP
and ADMIN_USER_COMMANDS_HELP
,
used by processDebugCommand(StringConnection, String, String, String)
}
when *HELP*
is requested by a debug/admin user.
GENERAL_COMMANDS_HELP
,
ADMIN_USER_COMMANDS_HELP
,
GameHandler.getDebugCommandsHelp()
public static boolean printedUsageAlready
printUsage(boolean)
.
private static java.io.BufferedReader sysInBuffered
System.in
for readPassword(String)
,
is null
until first call to that method.
Constructor Detail |
---|
public SOCServer(int p, int mc, java.lang.String databaseUserName, java.lang.String databasePassword) throws java.net.SocketException, java.io.EOFException, java.sql.SQLException
p
.
Most server threads are started here; you must start its main thread yourself.
Optionally connect to a database for user info and game stats.
No bots will be started here (PROP_JSETTLERS_STARTROBOTS
== 0),
call setupLocalRobots(int, int)
if bots are wanted.
In 1.1.07 and later, will also print game options to stderr if
any option defaults require a minimum client version, or if
hasSetGameOptions
is set.
p
- the TCP port that the server listens onmc
- the maximum number of connections allowed;
remember that robots count against this limit.databaseUserName
- the user name for accessing the databasedatabasePassword
- the password for the db user, or ""
java.net.SocketException
- If a network setup problem occurs
java.io.EOFException
- If db setup script ran successfully and server should exit now
java.sql.SQLException
- If db setup script failspublic SOCServer(int p, java.util.Properties props) throws java.net.SocketException, java.io.EOFException, java.sql.SQLException, java.lang.IllegalArgumentException
p
.
Most server threads are started here; you must start its main thread yourself.
Optionally connect to a database for user info and game stats.
The database properties are SOCDBHelper.PROP_JSETTLERS_DB_USER
and SOCDBHelper.PROP_JSETTLERS_DB_PASS
.
To run a DB setup script to create database tables, send its filename
or relative path as SOCDBHelper.PROP_JSETTLERS_DB_SCRIPT_SETUP
.
If a db URL or other DB properties are specified in props
, but SOCServer
can't successfully connect to that database, this constructor throws SQLException
;
for details see initSocServer(String, String, Properties)
.
Other constructors can't set those properties, and will instead
continue SOCServer
startup and run without any database.
Will also print game options to stderr if
any option defaults require a minimum client version, or if
hasSetGameOptions
is set.
SOCDBHelper.PROP_JSETTLERS_DB_SCRIPT_SETUP
will initialize the server environment, connect to the database, perform
a single task, and exit. This is called Utility Mode. In Utility Mode
the caller should not start threads or continue normal startup (Server Mode).
See hasUtilityModeProperty()
for more details.
For the password reset property SOCDBHelper.PROP_IMPL_JSETTLERS_PW_RESET
, the
caller will need to prompt for and change the password; this constructor will not do that.
p
- the TCP port that the server listens onprops
- null, or properties containing PROP_JSETTLERS_CONNECTIONS
and any other desired properties.
If props
is null, the properties will be created empty
and no bots will be started (PROP_JSETTLERS_STARTROBOTS
== 0).
If props
!= null but doesn't contain PROP_JSETTLERS_STARTROBOTS
,
the default value SOC_STARTROBOTS_DEFAULT
will be used.
props
may contain game option default values (property names starting
with PROP_JSETTLERS_GAMEOPT_PREFIX
).
Calls parseCmdline_GameOption(SOCGameOption, String, HashMap)
for each one found, to set its default (current) value. If a default scenario is
specified (game option "SC"
), the scenario may include game options which
conflict with those in props
: Consider calling checkScenarioOpts(Map, boolean, String)
to check for that and warn the user.
If you provide props
, consider checking for a jsserver.properties
file
(SOC_SERVER_PROPS_FILENAME
) and calling Properties.load(java.io.InputStream)
with it before calling this constructor.
java.net.SocketException
- If a network setup problem occurs
java.io.EOFException
- If db setup script ran successfully and server should exit now
java.sql.SQLException
- If db setup script fails, or need db but can't connect
java.lang.IllegalArgumentException
- If props
contains game options (jsettlers.gameopt.*
)
with bad syntax. See PROP_JSETTLERS_GAMEOPT_PREFIX
for expected syntax.
See parseCmdline_DashedArgs(String[])
for how game option properties are checked.
Throwable.getMessage()
will have problem details.PROPS_LIST
public SOCServer(java.lang.String s, int mc, java.lang.String databaseUserName, java.lang.String databasePassword) throws java.net.SocketException, java.io.EOFException, java.sql.SQLException
s
.
Most server threads are started here; you must start its main thread yourself.
Optionally connect to a database for user info and game stats.
No bots will be started here (PROP_JSETTLERS_STARTROBOTS
== 0),
call setupLocalRobots(int, int)
if bots are wanted.
In 1.1.07 and later, will also print game options to stderr if
any option defaults require a minimum client version, or if
hasSetGameOptions
is set.
s
- the stringport that the server listens on.
If this is a "practice game" server on the user's local computer,
please use PRACTICE_STRINGPORT
.mc
- the maximum number of connections allowed;
remember that robots count against this limit.databaseUserName
- the user name for accessing the databasedatabasePassword
- the password for the user
java.net.SocketException
- If a network setup problem occurs
java.io.EOFException
- If db setup script ran successfully and server should exit now
java.sql.SQLException
- If db setup script failsMethod Detail |
---|
private void initSocServer(java.lang.String databaseUserName, java.lang.String databasePassword, java.util.Properties props) throws java.net.SocketException, java.io.EOFException, java.sql.SQLException, java.lang.IllegalArgumentException
System.err
.
Sets game option default values via init_propsSetGameopts(Properties)
.
Starts all server threads except the main thread, unless constructed in Utility Mode
(hasUtilityModeProp
).
If PROP_JSETTLERS_STARTROBOTS
is specified, those aren't started until serverUp()
.
If there are problems with the network setup (Server.error
!= null),
this method will throw SocketException
.
If problems running a db setup script
,
this method will throw SQLException
.
If we can't connect to a database, but it looks like we need one (because
SOCDBHelper.PROP_JSETTLERS_DB_URL
, SOCDBHelper.PROP_JSETTLERS_DB_DRIVER
or SOCDBHelper.PROP_JSETTLERS_DB_JAR
is specified in props
),
this method will throw SQLException
.
props
contains the password reset parameter
SOCDBHelper.PROP_IMPL_JSETTLERS_PW_RESET
, the server does not complete its startup;
this method will set hasUtilityModeProp
and (only for setup script) throw EOFException
.
For the password reset parameter, the caller will need to prompt for and change the password; this method will not do that.
databaseUserName
- Used for DB connect - not retaineddatabasePassword
- Used for DB connect - not retainedprops
- null, or properties containing PROP_JSETTLERS_CONNECTIONS
and any other desired properties.
If props
is null, the properties will be created empty
and no bots will be started (PROP_JSETTLERS_STARTROBOTS
== 0).
If props
!= null but doesn't contain PROP_JSETTLERS_STARTROBOTS
,
the default value SOC_STARTROBOTS_DEFAULT
will be used.
props
may contain game option default values (property names starting
with PROP_JSETTLERS_GAMEOPT_PREFIX
).
Calls parseCmdline_GameOption(SOCGameOption, String, HashMap)
for each one found, to set its default (current) value. If a default scenario is
specified (game option "SC"
), the scenario may include game options which
conflict with those in props
: Consider calling checkScenarioOpts(Map, boolean, String)
to check for that and warn the user.
java.net.SocketException
- If a network setup problem occurs
java.io.EOFException
- If db setup script ran successfully and server should exit now;
thrown in Utility Mode (hasUtilityModeProp
).
java.sql.SQLException
- If db setup script fails, or need db but can't connect
java.lang.IllegalArgumentException
- If props
contains game options (jsettlers.gameopt.*
)
with bad syntax. See PROP_JSETTLERS_GAMEOPT_PREFIX
for expected syntax.
See parseCmdline_DashedArgs(String[])
for how game option properties are checked.
Throwable.getMessage()
will have problem details.private static int getConfigIntProperty(java.util.Properties props, java.lang.String pName, int pDefault)
Before v2.0.00, this method was init_getIntProperty.
props
- Properties to look in, such as props
, or null for pDefaultpName
- Property namepDefault
- Default value to use if not found or not parsable
getConfigBoolProperty(Properties, String, boolean)
private static boolean getConfigBoolProperty(java.util.Properties props, java.lang.String pName, boolean pDefault)
props
- Properties to look in, such as props
, or null for pDefault
Before v2.0.00, this method was init_getBoolProperty.
pName
- Property namepDefault
- Default value to use if not found or not parsable
getConfigIntProperty(Properties, String, int)
public void serverUp() throws java.lang.IllegalStateException
PROP_JSETTLERS_STARTROBOTS
is specified, starts those SOCRobotClient
s now.
If PROP_JSETTLERS_BOTS_BOTGAMES_TOTAL
is specified, waits briefly and then
calls startRobotOnlyGames(boolean)
.
Once this method completes, server begins its main loop of listening for incoming client connections, and starting a Thread for each one to handle that client's messages.
serverUp
in class Server
java.lang.IllegalStateException
- If server was constructed in Utility Mode and shouldn't continue
normal startup; see hasUtilityModeProperty()
for details.private final java.lang.String generateRobotCookie()
robotCookie
.
Currently a lowercase hex string; format or length does not have to be compatible
between versions. The contents are randomly generated for each server run.
public void connectToChannel(StringConnection c, java.lang.String ch)
c
- the Connection to be addedch
- the name of the channelpublic boolean leaveChannel(StringConnection c, java.lang.String ch, boolean destroyIfEmpty, boolean channelListLock)
c
leaves the channel ch
.
If the channel becomes empty after removing c
, this method can destroy it.
Locks: Must have channelList.takeMonitorForChannel(ch)
when calling this method.
May or may not have SOCChannelList.takeMonitor()
, see channelListLock
parameter.
c
- the connectionch
- the channeldestroyIfEmpty
- if true, this method will destroy the channel if it's now empty.
If false, the caller must call destroyChannel(String)
before calling SOCChannelList.releaseMonitor()
.channelListLock
- true if we have the SOCChannelList.takeMonitor()
lock
when called; false if it must be acquired and released within this method
destroyIfEmpty
is false.protected final void destroyChannel(java.lang.String ch)
SOCClientData.getcurrentCreatedChannels()
.
Calls SOCChannelList.deleteChannel(String)
.
Locks: Must have channelList
.takeMonitor()
before calling this method.
ch
- Name of the channel to destroyleaveChannel(StringConnection, String, boolean, boolean)
public boolean connectToGame(StringConnection c, java.lang.String gaName, java.util.Map<java.lang.String,SOCGameOption> gaOpts) throws SOCGameOptionVersionException, java.lang.IllegalArgumentException
createGameAndBroadcast(StringConnection, String, Map, int, boolean, boolean)
.
After this, human players are free to join, until someone clicks "Start Game". At that point, server will look for robots to fill empty seats.
c
- the Connection to be added to the game; its name, version, and locale should already be set.gaName
- the name of the game. Not validated or trimmed, see
createOrJoinGameIfUserOK(StringConnection, String, String, String, Map)
for that.gaOpts
- if creating a game with options, its SOCGameOption
s; otherwise null.
Should already be validated, by calling
SOCGameOption.adjustOptionsToKnown(Map, Map, boolean)
with doServerPreadjust true.
c
was not a member of the game before, or if new game created;
false if c
was already in this game
SOCGameOptionVersionException
- if asking to create a game (gaOpts != null),
but client's version is too low to join because of a
requested game option's minimum version in gaOpts.
Calculated via SOCGameOption.optionsNewerThanVersion(int, boolean, boolean, Map)
.
(this exception was added in 1.1.07)
java.lang.IllegalArgumentException
- if client's version is too low to join for any
other reason. (this exception was added in 1.1.06)joinGame(SOCGame, StringConnection, boolean, boolean)
,
#handleSTARTGAME(StringConnection, SOCStartGame)
,
handleJOINGAME(StringConnection, SOCJoinGame)
private SOCGame createGameAndBroadcast(StringConnection c, java.lang.String gaName, java.util.Map<java.lang.String,SOCGameOption> gaOpts, int gVers, boolean isBotsOnly, boolean hasGameListMonitor)
connectToGame(StringConnection, String, Map)
.
The new game is created with SOCGameListAtServer.createGame(String, String, String, Map, GameHandler)
and will expire in SOCGameListAtServer.GAME_TIME_EXPIRE_MINUTES
unless extended during play.
The broadcast will send SOCNewGameWithOptions
if gaOpts != null
, SOCNewGame
otherwise.
If some connected clients are older than gVers
, the message sent to those older clients will
let them know they can't connect to the new game.
Locks: Uses SOCGameList.takeMonitor()
/ SOCGameList.releaseMonitor()
;
see hasGameListMonitor
parameter.
c
- the Connection creating and owning this game; its name, version, and locale should already be set.
This client connection will be added as a member of the game, and its SOCClientData.createdGame()
will be called. Can be null, especially if isBotsOnly
.gaName
- the name of the game, no game should exist yet with this name. Not validated or trimmed, see
createOrJoinGameIfUserOK(StringConnection, String, String, String, Map)
for that.gaOpts
- if creating a game with options, its SOCGameOption
s; otherwise null.
Should already be validated, by calling
SOCGameOption.adjustOptionsToKnown(Map, Map, boolean)
with doServerPreadjust true.gVers
- Game's minimum version, from
SOCVersionedItem.itemsMinimumVersion
(gaOpts)
, or -1 if null gaOptsisBotsOnly
- True if the game's only players are bots, no humans and no ownerhasGameListMonitor
- True if caller holds the SOCGameList.takeMonitor()
lock already.
If true, this method won't take or release that monitor. Otherwise will take it before creating
the game, and release it before calling Server.broadcast(String)
.
public boolean leaveGame(StringConnection c, java.lang.String gm, boolean destroyIfEmpty, boolean gameListLock)
If the game becomes empty after removing c
, this method can destroy it if all these
conditions are true (determined by GameHandler.leaveGame(SOCGame, StringConnection)
):
c
was the last non-robot player
SOCGame.isBotsOnly
flag is false
Locks: Has gameList.takeMonitorForGame(gm)
when calling this method; should not have SOCGame.takeMonitor()
.
May or may not have SOCGameList.takeMonitor()
, see gameListLock
parameter.
c
- the connection; if c is being dropped because of an error,
this method assumes that StringConnection.disconnect()
has already been called. This method won't exclude c from
any communication about leaving the game, in case they are
still connected and in other games.gm
- the gamedestroyIfEmpty
- if true, this method will destroy the game if it's now empty.
If false, the caller must call destroyGame(String)
before calling SOCGameList.releaseMonitor()
.gameListLock
- true if we have the SOCGameList.takeMonitor()
lock when called;
false if it must be acquired and released within this method
destroyIfEmpty
is false.int[] robotShuffleForJoin()
robots
robots
}.size() - 1public boolean setupLocalRobots(int numFast, int numSmart)
Before 1.1.09, this method was part of SOCPlayerClient.
numFast
- number of fast robots, with FAST_STRATEGY
numSmart
- number of smart robots, with SMART_STRATEGY
SOCPlayerClient.startPracticeGame()
,
SOCPlayerClient.GameAwtDisplay.startLocalTCPServer(int)
,
startRobotOnlyGames(boolean)
,
SOCLocalRobotClient
public void destroyGame(java.lang.String gm)
SOCClientData.getCurrentCreatedGames()
.
Note that if this game had the SOCGame.isBotsOnly
flag, and numRobotOnlyGamesRemaining
> 0,
will call startRobotOnlyGames(boolean)
.
Locks: Must have gameList
.takeMonitor()
before calling this method.
gm
- Name of the game to destroyleaveGame(StringConnection, String, boolean, boolean)
,
destroyGameAndBroadcast(String, String)
public void destroyGameAndBroadcast(java.lang.String gaName, java.lang.String descForStackTrace)
SOCGameList.takeMonitor()
, destroyGame(String)
,
SOCGameList.releaseMonitor()
, and broadcast
(SOCDeleteGame
).
gaName
- Game name to destroydescForStackTrace
- Activity description in case of exception thrown from destroyGame;
will debug-print a mesasge "Exception in " + desc, followed by a stack trace.public java.util.Collection<java.lang.String> getGameNames()
public SOCGame getGame(java.lang.String gaName)
gaName
- Game name
null
if none found in game listpublic int getGameState(java.lang.String gm)
gm
- Game name
public java.util.Map<java.lang.String,SOCGameOption> getGameOptions(java.lang.String gm)
gm
- Game name
public final boolean hasUtilityModeProperty()
Utility Mode may also set a status message, see getUtilityModeMessage()
.
The current Utility Mode properties/arguments are:
SOCDBHelper.PROP_JSETTLERS_DB_SCRIPT_SETUP
property
--pw-reset=username
argument
public final java.lang.String getUtilityModeMessage()
hasUtilityModeProperty()
, get the optional status message to print before exiting.
null
public static java.util.Map<java.lang.String,SOCGameOption> localizeKnownOptions(java.util.Locale loc, boolean updateStaticKnownOpts)
loc
- Client's locale for StringManager i18n lookups:
smgr.get("gameopt." + SOCGameOption.key
)updateStaticKnownOpts
- If true, localize each SOCGameOption.desc
in the
static set of known options used by SOCGameOption.getOption(String, boolean)
and
SOCGameOption.getAllKnownOptions()
; for use only by client's practice-game server
SOCGameOption.getAllKnownOptions()
, with descriptions localized if availableStringConnection getConnection(java.lang.String connKey)
connKey
- Client name (Object key data), as in StringConnection.getData()
; if null, returns null
public void leaveAllChannels(StringConnection c)
c
is leaving the server; remove from all channels it was in.
In channels where c
was the last connection, calls destroyChannel(String)
.
c
- the connectionpublic void leaveAllGames(StringConnection c)
c
is leaving the server; remove from all games it was in.
In games where c
was the last human player, calls destroyGame(String)
.
c
- the connectionpublic void messageToChannel(java.lang.String ch, SOCMessage mes)
ch
- the name of the channelmes
- the message to sendpublic void messageToChannelWithMon(java.lang.String ch, SOCMessage mes)
ch
- the name of the channelmes
- the message to sendpublic void messageToPlayer(StringConnection c, SOCMessage mes)
c
- the player connectionmes
- the message to sendpublic void messageToPlayer(StringConnection c, java.lang.String ga, java.lang.String txt)
SOCGameServerText
or SOCGameTextMsg
game text message to a player.
Equivalent to: messageToPlayer(conn, new SOCGameServerText
(ga, txt));
c
- the player connection; if their version is 2.0.00 or newer,
they will be sent SOCGameServerText
, otherwise SOCGameTextMsg
.ga
- game nametxt
- the message text to sendmessageToPlayerKeyed(StringConnection, String, String)
public final void messageToPlayerKeyed(StringConnection c, java.lang.String gaName, java.lang.String key)
SOCGameServerText
game text message to a player.
Equivalent to: messageToPlayer(conn, new SOCGameServerText
(ga,
c.getLocalized(key)
));
c
- the player connection; if their version is 2.0.00 or newer,
they will be sent SOCGameServerText
, otherwise SOCGameTextMsg
.
Null c
is ignored and not an error.gaName
- game namekey
- the message localization key, from StringManager.get(String)
, to look up and send text ofmessageToPlayerKeyed(StringConnection, String, String, Object...)
public final void messageToPlayerKeyed(StringConnection c, java.lang.String gaName, java.lang.String key, java.lang.Object... args)
SOCGameServerText
game text message with arguments to a player.
Equivalent to: messageToPlayer(conn, new SOCGameServerText
(ga,
c.getLocalized(key, args)
));
The localized message text must be formatted as in MessageFormat
:
Placeholders for args
are {0} etc, single-quotes must be repeated: ''
.
c
- the player connection; if their version is 2.0.00 or newer,
they will be sent SOCGameServerText
, otherwise SOCGameTextMsg
.
Null c
is ignored and not an error.gaName
- game namekey
- the message localization key, from StringManager.get(String)
, to look up and send text ofargs
- Any parameters within txt
's placeholdersmessageToPlayerKeyed(StringConnection, String, String)
,
messageToPlayerKeyedSpecial(StringConnection, SOCGame, String, Object...)
public final void messageToPlayerKeyedSpecial(StringConnection c, SOCGame ga, java.lang.String key, java.lang.Object... args)
SOCGameServerText
game text message with arguments to a player,
with special formatting like {0,rsrcs}.
Equivalent to: messageToPlayer(conn, new SOCGameServerText
(ga,
c.getLocalizedSpecial(ga, key, args)
));
The localized message text must be formatted as in MessageFormat
:
Placeholders for args
are {0} etc, single-quotes must be repeated: ''
.
For the SoC-specific parameters such as {0,rsrcs}, see the javadoc for
SOCStringManager.getSpecial(SOCGame, String, Object...)
.
c
- the player connection; if their version is 2.0.00 or newer,
they will be sent SOCGameServerText
, otherwise SOCGameTextMsg
.
Null c
is ignored and not an error.ga
- the gamekey
- the message localization key, from StringManager.get(String)
, to look up and send text ofargs
- Any parameters within txt
's placeholdersmessageToPlayerKeyed(StringConnection, String, String, Object...)
,
messageToPlayerKeyed(StringConnection, String, String)
public void messageToGame(java.lang.String ga, SOCMessage mes)
Locks: Takes, releases SOCGameList.takeMonitorForGame(String)
.
ga
- the name of the gamemes
- the message to send. If mes is a SOCGameTextMsg whose
text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)messageToGame(String, String)
,
messageToGameWithMon(String, SOCMessage)
,
messageToGameForVersions(SOCGame, int, int, SOCMessage, boolean)
public void messageToGame(java.lang.String ga, java.lang.String txt)
Do not pass SOCSomeMessage.toCmd() into this method; the message type number will be GAMESERVERTEXT, not the desired SOMEMESSAGE.
Client versions older than v2.0.00 will be sent
SOCGameTextMsg
(ga, SERVERNAME
, txt).
Locks: Takes, releases SOCGameList.takeMonitorForGame(String)
.
ga
- the name of the gametxt
- the message text to send. If
text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)messageToGameKeyed(SOCGame, boolean, String)
,
messageToGameKeyed(SOCGame, boolean, String, Object...)
,
messageToGame(String, SOCMessage)
,
messageToGameWithMon(String, SOCMessage)
,
messageToGameExcept(String, StringConnection, String, boolean)
public void messageToGameKeyedType(SOCGame ga, SOCKeyedMessage msg, boolean takeMon)
messageToGame(String, SOCMessage)
but calls each member connection's
c.getLocalized(key)
for the localized text to send.
Locks: If takeMon
is true, takes and releases
gameList.takeMonitorForGame(gameName)
.
Otherwise call gameList.takeMonitorForGame(gameName)
before calling this method.
ga
- The gamemsg
- The data message to be sent after localizing text.
This message's fields are not changed here, the localization results are not kept with msg
.takeMon
- Should this method take and release game's monitor via
gameList.takeMonitorForGame(gameName)
?
True unless caller already holds that monitor.messageToGameKeyed(SOCGame, boolean, String)
,
messageToGameKeyed(SOCGame, boolean, String, Object...)
public void messageToGameKeyed(SOCGame ga, boolean takeMon, java.lang.String key) throws java.util.MissingResourceException
SOCGameServerText
game text message to a game.
Same as messageToGame(String, String)
but calls each member connection's
c.getLocalized(key)
for the localized text to send.
Client versions older than v2.0.00 will be sent SOCGameTextMsg
(ga, SERVERNAME
, txt).
Locks: If takeMon
is true, takes and releases SOCGameList.takeMonitorForGame(String)
.
Otherwise call gameList.takeMonitorForGame(gaName)
before calling this method.
ga
- the game objecttakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
True unless caller already holds that monitor.key
- the message localization key, from StringManager.get(String)
, to look up and send text of.
If its localized text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeExceptionmessageToGameKeyed(SOCGame, boolean, String, Object...)
,
messageToGameKeyedSpecial(SOCGame, boolean, String, Object...)
,
messageToGameKeyedSpecialExcept(SOCGame, boolean, StringConnection, String, Object...)
,
messageToGameKeyedType(SOCGame, SOCKeyedMessage, boolean)
,
messageToGame(String, String)
public void messageToGameKeyed(SOCGame ga, boolean takeMon, java.lang.String key, java.lang.Object... params) throws java.util.MissingResourceException
SOCGameServerText
game text message (with parameters) to a game.
Same as messageToGame(String, String)
but calls each member connection's
c.getLocalized(key)
for the localized text to send.
Client versions older than v2.0.00 will be sent SOCGameTextMsg
(ga, SERVERNAME
, txt).
Locks: If takeMon
is true, takes and releases SOCGameList.takeMonitorForGame(String)
.
Otherwise call gameList.takeMonitorForGame(gaName)
before calling this method.
ga
- the game objecttakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
True unless caller already holds that monitor.key
- the message localization key, from StringManager.get(String)
, to look up and send text of.
If its localized text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)params
- Objects to use with {0}, {1}, etc in the localized string
by calling MessageFormat.format(String, Object...)
.
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeExceptionmessageToGameKeyed(SOCGame, boolean, String)
,
messageToGameKeyedSpecial(SOCGame, boolean, String, Object...)
,
messageToGameKeyedSpecialExcept(SOCGame, boolean, StringConnection, String, Object...)
,
messageToGameKeyedType(SOCGame, SOCKeyedMessage, boolean)
,
messageToGame(String, String)
public final void messageToGameKeyedSpecial(SOCGame ga, boolean takeMon, java.lang.String key, java.lang.Object... params) throws java.util.MissingResourceException, java.lang.IllegalArgumentException
SOCGameServerText
game text message (with parameters) to a game,
optionally with special formatting like {0,rsrcs}, optionally excluding one connection.
Same as messageToGame(String, String)
but calls each member connection's
c.getLocalizedSpecial(...)
for the localized text to send.
For the SoC-specific parameters such as {0,rsrcs}, see the javadoc for
SOCStringManager.getSpecial(SOCGame, String, Object...)
.
Client versions older than v2.0.00 will be sent SOCGameTextMsg
(ga, SERVERNAME
, txt).
Locks: If takeMon
is true, takes and releases SOCGameList.takeMonitorForGame(String)
.
Otherwise call gameList.takeMonitorForGame(gaName)
before calling this method.
ga
- the game objecttakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
True unless caller already holds that monitor.key
- the message localization key, from StringManager.get(String)
, to look up and send text of.
If its localized text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)params
- Objects to use with {0}, {1}, etc in the localized string
by calling MessageFormat.format(String, Object...)
.
These objects can include SOCResourceSet
or pairs of
Integers for a resource count and type; see SOCStringManager.getSpecial(SOCGame, String, Object...)
.
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeException
java.lang.IllegalArgumentException
- if the localized pattern string has a parse error (closing '}' brace without opening '{' brace, etc)messageToGameKeyedSpecialExcept(SOCGame, boolean, StringConnection, String, Object...)
,
messageToGameKeyed(SOCGame, boolean, String)
,
messageToGame(String, String)
public final void messageToGameKeyedSpecialExcept(SOCGame ga, boolean takeMon, StringConnection ex, java.lang.String key, java.lang.Object... params) throws java.util.MissingResourceException, java.lang.IllegalArgumentException
SOCGameServerText
game text message (with parameters) to a game,
optionally with special formatting like {0,rsrcs}, optionally excluding one connection.
Same as messageToGame(String, String)
but calls each member connection's
c.getLocalizedSpecial(...)
for the
localized text to send.
ga
- the game objecttakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
True unless caller already holds that monitor.ex
- the excluded connection, or null
key
- the message localization key, from StringManager.get(String)
, to look up and send text of.
If its localized text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)params
- Objects to use with {0}, {1}, etc in the localized string
by calling MessageFormat.format(String, Object...)
.
These objects can include SOCResourceSet
or pairs of
Integers for a resource count and type; see SOCStringManager.getSpecial(SOCGame, String, Object...)
.
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeException
java.lang.IllegalArgumentException
- if the localized pattern string has a parse error (closing '}' brace without opening '{' brace, etc)messageToGameKeyedSpecialExcept(SOCGame, boolean, List, String, Object...)
,
messageToGameKeyed(SOCGame, boolean, String)
,
messageToGame(String, String)
public final void messageToGameKeyedSpecialExcept(SOCGame ga, boolean takeMon, java.util.List<StringConnection> ex, java.lang.String key, java.lang.Object... params) throws java.util.MissingResourceException, java.lang.IllegalArgumentException
SOCGameServerText
game text message (with parameters) to a game,
optionally with special formatting like {0,rsrcs}, optionally excluding some connections.
Same as messageToGame(String, String)
but calls each member connection's
c.getLocalizedSpecial(...)
for the
localized text to send.
ga
- the game objecttakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
True unless caller already holds that monitor.ex
- the excluded connections, or null
key
- the message localization key, from StringManager.get(String)
, to look up and send text of.
If its localized text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)params
- Objects to use with {0}, {1}, etc in the localized string
by calling MessageFormat.format(String, Object...)
.
These objects can include SOCResourceSet
or pairs of
Integers for a resource count and type; see SOCStringManager.getSpecial(SOCGame, String, Object...)
.
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeException
java.lang.IllegalArgumentException
- if the localized pattern string has a parse error (closing '}' brace without opening '{' brace, etc)messageToGameKeyedSpecialExcept(SOCGame, boolean, StringConnection, String, Object...)
,
messageToGameKeyed(SOCGame, boolean, String)
,
messageToGame(String, String)
private final void impl_messageToGameKeyedSpecial(SOCGame ga, boolean takeMon, java.util.List<StringConnection> members, StringConnection ex, boolean fmtSpecial, java.lang.String key, java.lang.Object... params) throws java.util.MissingResourceException, java.lang.IllegalArgumentException
messageToGameKeyedSpecial
and messageToGameKeyedSpecialExcept
.
ga
- the game objecttakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
True unless caller already holds that monitor.members
- Game members to send to, from SOCGameListAtServer.getMembers(String)
.
If we're excluding several members of the game, make a new list from getMembers, remove them from
that list, then pass it to this method.ex
- the excluded connection, or null
fmtSpecial
- Should this method call SOCStringManager.getSpecial(SOCGame, String, Object...)
instead of the usual StringManager.get(String, Object...)
?key
- the message localization key, from StringManager.get(String)
, to look up and send text of.
If its localized text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)params
- Objects to use with {0}, {1}, etc in the localized string
by calling MessageFormat.format(String, Object...)
.
If fmtSpecial
, these objects can include SOCResourceSet
or pairs of
Integers for a resource count and type; see SOCStringManager.getSpecial(SOCGame, String, Object...)
.
java.util.MissingResourceException
- if no string can be found for key
; this is a RuntimeException
java.lang.IllegalArgumentException
- if the localized pattern string has a parse error (closing '}' brace without opening '{' brace, etc)public void messageToGameWithMon(java.lang.String ga, SOCMessage mes)
Locks: MUST HAVE THE
gameList.takeMonitorForGame(ga)
before calling this method.
ga
- the name of the gamemes
- the message to sendmessageToGame(String, SOCMessage)
,
messageToGameKeyed(SOCGame, boolean, String)
,
messageToGameForVersions(SOCGame, int, int, SOCMessage, boolean)
public void messageToGameExcept(java.lang.String gn, StringConnection ex, java.lang.String txt, boolean takeMon)
SERVERNAME
, txt), takeMon);
Do not pass SOCSomeMessage.toCmd() into this method; the message type number will be GAMETEXTMSG, not the desired SOMEMESSAGE.
gn
- the name of the gameex
- the excluded connection, or nulltxt
- the message text to send.
If you need to format the message (with placeholders for i18n),
call MessageFormat
.format(fmt, args) on it first.
If text begins with ">>>", the client should consider this
an urgent message, and draw the user's attention in some way.
(See messageToGameUrgent(String, String)
)
takeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
True unless caller already holds that monitor.messageToGame(String, String)
,
messageToGameExcept(String, StringConnection, SOCMessage, boolean)
public void messageToGameExcept(java.lang.String gn, java.util.Vector<StringConnection> ex, SOCMessage mes, boolean takeMon)
gn
- the name of the gameex
- the list of exceptionsmes
- the messagetakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?messageToGameExcept(String, StringConnection, SOCMessage, boolean)
public void messageToGameExcept(java.lang.String gn, StringConnection ex, SOCMessage mes, boolean takeMon)
gn
- the name of the gameex
- the excluded connection, or nullmes
- the messagetakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?messageToGameExcept(String, StringConnection, String, boolean)
,
messageToGameExcept(String, Vector, SOCMessage, boolean)
,
messageToGameForVersionsExcept(SOCGame, int, int, StringConnection, SOCMessage, boolean)
public final void messageToGameForVersions(SOCGame ga, int vmin, int vmax, SOCMessage mes, boolean takeMon)
ga
- the gamevmin
- Minimum version to send to, or -1. Same format as
Version.versionNumber()
and StringConnection.getVersion()
.vmax
- Maximum version to send to, or Integer.MAX_VALUE
mes
- the messagetakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
If the game's clients are all older than vmin or
newer than vmax, nothing happens and the monitor isn't taken.public final void messageToGameForVersionsExcept(SOCGame ga, int vmin, int vmax, StringConnection ex, SOCMessage mes, boolean takeMon)
ga
- the gamevmin
- Minimum version to send to, or -1. Same format as
Version.versionNumber()
and StringConnection.getVersion()
.vmax
- Maximum version to send to, or Integer.MAX_VALUE
ex
- the excluded connection, or nullmes
- the messagetakeMon
- Should this method take and release
game's monitor via SOCGameList.takeMonitorForGame(String)
?
If the game's clients are all older than vmin or
newer than vmax, nothing happens and the monitor isn't taken.messageToGameExcept(String, StringConnection, SOCMessage, boolean)
public void messageToGameUrgent(java.lang.String ga, java.lang.String mes)
Locks: Like messageToGame(String, String)
, will take and release the game's monitor.
ga
- the name of the gamemes
- the message to send. If mes does not begin with ">>>",
will prepend ">>> " before sending mes.public void leaveConnection(StringConnection c)
This method is called within a per-client thread, after connection is removed from conns collection and version collection, and after c.disconnect() has been called.
leaveConnection
in class Server
c
- the connectionpublic boolean newConnection1(StringConnection c)
If we already have maxConnections
named clients, reject this new one
by sending SOCRejectConnection
.
If the connection is accepted, it's added to Server.unnamedConns
until the
player "names" it by joining or creating a game under their player name.
Other communication is then done, in newConnection2(StringConnection)
.
Also set client's "assumed version" to -1, until we have sent and received a VERSION message.
This method is called within a per-client thread. You can send to client, but can't yet receive messages from them.
SYNCHRONIZATION NOTE: During the call to newConnection1, the monitor lock of
Server.unnamedConns
is held. Thus, defer as much as possible until
newConnection2(StringConnection)
(after the connection is accepted).
newConnection1
in class Server
c
- the new Connection
StringConnection.disconnectSoft()
.Server.addConnection(StringConnection)
,
newConnection2(StringConnection)
,
nameConnection(StringConnection, boolean)
protected void newConnection2(StringConnection c)
SOCChannels
, SOCGames
)) when a new
connection comes, part 2 - c has been accepted and added to a connection list.
Unlike newConnection1(StringConnection)
,
no connection-list locks are held when this method is called.
Client's SOCClientData
appdata is set here.
This method is called within a per-client thread. You can send to client, but can't yet receive messages from them.
newConnection2
in class Server
private void nameConnection(StringConnection c, boolean isReplacing) throws java.lang.IllegalArgumentException
Server.nameConnection(StringConnection)
to move the connection
from the unnamed to the named connection list. Increments numberOfUsers
.
If isReplacing
:
SOCClientData.copyClientPlayerStats(SOCClientData)
for win/loss record and current game and channel count
SOCServerPing(-1)
c
- Connected client; its key data (StringConnection.getData()
) must not be nullisReplacing
- Are we replacing / taking over a current connection?
java.lang.IllegalArgumentException
- If c isn't already connected, if c.getData() returns null,
or if nameConnection has previously been called for this connection.public void sendGameList(StringConnection c, int prevVers)
SOCGames.MARKER_THIS_GAME_UNJOINABLE
).
If entire list, then depending on client's version, the message sent will be
either GAMES
or GAMESWITHOPTIONS
.
If set of changed games, sent as matching pairs of DELETEGAME
and either NEWGAME
or NEWGAMEWITHOPTIONS
.
There are 2 possible scenarios for when this method is called:
- (A) Sending game list to client, for the first time: Iterate through all games, looking for ones the client's version is capable of joining. If not capable, mark the game name as such before sending it to the client. (As a special case, very old client versions "can't know" about the game they can't join, because they don't recognize the marker.) Also set the client data's hasSentGameList flag.
- (B) The client didn't give its version, and was thus identified as an old version. Now we know its newer true version, so we must tell it about games that it can now join, which couldn't have been joined by the older assumed version. So: Look for games with those criteria.
Sending the list is done here, and not in newConnection2, because we must first know the client's version.
The minimum version which recognizes the "can't join" marker is
1.1.06 (SOCGames.VERSION_FOR_UNJOINABLE
). Older clients won't be sent
the game names they can't join.
Locks: Calls SOCGameList.takeMonitor()
/ releaseMonitor
c
- Client's connection; will call getVersion() on itprevVers
- Previously assumed version of this client;
if re-sending the list, should be less than c.getVersion.private int checkNickname(java.lang.String n, StringConnection newc, boolean withPassword)
a name is ok if it hasn't been used yet, isn't the server's name
,
and (since 1.1.07) passes SOCMessage.isSingleLineAndSafe(String)
.
The "take over" option is used for reconnect when a client loses
connection, and server doesn't realize it.
A new connection can "take over" the name after a timeout; check
the return value.
(After NICKNAME_TAKEOVER_SECONDS_SAME_IP
or
NICKNAME_TAKEOVER_SECONDS_DIFFERENT_IP
seconds)
When taking over, the new connection's client version must be able
to join all games that the old connection is playing, as returned
by gameList.playerGamesMinVersion
.
n
- the namenewc
- A new incoming connection, asking for this namewithPassword
- Did the connection supply a password?
checkNickname_getRetryText(int)
private static final java.lang.String checkNickname_getRetryText(int nameTimeout)
NICKNAME_TAKEOVER_SECONDS_SAME_IP
,
NICKNAME_TAKEOVER_SECONDS_DIFFERENT_IP
)
nameTimeout
- Number of seconds before trying to reconnect
private static final java.lang.String checkNickname_getVersionText(int needsVersion)
needsVersion
- Version number required to take it over;
a positive integer in the same format as SOCGame.getClientVersionMinRequired()
MSG_NICKNAME_ALREADY_IN_USE_NEWER_VERSION_P1
.public boolean processFirstCommand(java.lang.String str, StringConnection con)
processFirstCommand
in class Server
str
- Contents of first message from the clientcon
- Connection (client) sending this message
processCommand(String, StringConnection)
.public void processCommand(java.lang.String s, StringConnection c)
Called from the single 'treater' thread. Do not block or sleep because this is single-threaded.
The first message from a client is treated by
processFirstCommand(String, StringConnection)
instead.
Note: When there is a choice, always use local information over information from the message. For example, use the nickname from the connection to get the player information rather than the player information from the message. This makes it harder to send false messages making players do things they didn't want to do.
processCommand
in class Server
s
- Contents of message from the clientc
- Connection (client) sending this messagepublic boolean processDebugCommand(StringConnection debugCli, java.lang.String ga, java.lang.String dcmd, java.lang.String dcmdU)
GameHandler.processDebugCommand(StringConnection, String, String, String)
to check for those.
Check allowDebugUser
before calling this method.
For list of commands see GENERAL_COMMANDS_HELP
, DEBUG_COMMANDS_HELP
,
ADMIN_USER_COMMANDS_HELP
, and GameHandler.getDebugCommandsHelp()
.
"Unprivileged" general commands are handled by
handleGAMETEXTMSG(StringConnection, SOCGameTextMsg)
.
debugCli
- Client sending the potential debug commandga
- Game in which the message is sentdcmd
- Text message which may be a debug commanddcmdU
- dcmd
as uppercase, for efficiency (it's already been uppercased in caller)
dcmd
is a recognized debug command, false otherwisepublic void stopServer()
stopServer
in class Server
public void stopServer(java.lang.String stopMsg)
stopMsg
- Final text message to send to all connected clients, or null.
Will be sent as a SOCBCastTextMsg
.
As always, if message starts with ">>" it will be considered urgent.private int authOrRejectClientUser(StringConnection c, java.lang.String msgUser, java.lang.String msgPass, int cliVers, boolean doNameConnection, boolean allowTakeover)
PLAYER_NAME_MAX_LENGTH
, name
in use but not timed out versus takeover, etc. Calls checkNickname(String, StringConnection, boolean)
and authenticateUser(StringConnection, String, String)
.
If not okay, sends client a SOCStatusMessage
with an appropriate status code.
If this user is already logged into another connection, checks here whether this new
replacement connection can "take over" the existing one according to a timeout calculation
in checkNickname(String, StringConnection, boolean)
.
If this connection isn't already logged on and named (c.getData()
== null
) and all checks pass: Unless doNameConnection
is false, calls
c.setData(msgUser)
and
nameConnection(c, isTakingOver)
before
returning AUTH_OR_REJECT__OK
or AUTH_OR_REJECT__TAKING_OVER
.
If this connection is already logged on and named (c.getData()
!= null
),
does nothing. Won't check username or password, just returns AUTH_OR_REJECT__OK
.
c
- Client's connectionmsgUser
- Client username (nickname) to validate and authenticate; will be trim()med
.msgPass
- Password to supply to authenticateUser(StringConnection, String, String)
,
or ""; will be trim()med
.cliVers
- Client version, from StringConnection.getVersion()
doNameConnection
- True if successful auth of an unnamed connection should have this method call
c.setData(msgUser)
and
nameConnection(c, isTakingOver)
.
For the usual connect sequence, callers will want true
. Some callers might want to check
other things after this method and possibly reject the connection at that point; they will want
false
. Those callers must remember to call c.setData(msgUser)
and
nameConnection(c, (result == AUTH_OR_REJECT__TAKING_OVER
)) themselves to finish
authenticating a connection.
allowTakeover
- True if the new connection can "take over" an older connection in response to the
message it sent. If true, the caller must be prepared to send all game info/channel info that the
old connection had joined, so the new connection has full info to participate in them.
AUTH_OR_REJECT__FAILED
,
AUTH_OR_REJECT__OK
, or (only if allowTakeover
) AUTH_OR_REJECT__TAKING_OVER
private boolean authenticateUser(StringConnection c, java.lang.String userName, java.lang.String password)
c
- the user's connectionuserName
- the user's nickname; trim before callingpassword
- the user's password; trim before calling
private boolean isUserDBUserAdmin(java.lang.String uname, boolean requireList)
databaseUserAdmins
whitelist, if that whitelist is being used?
uname
- Username to check; if null, returns false.requireList
- If true, the whitelist cannot be null.
If false, this function returns true for any user when we aren't using the whitelist and its field is null.
requireList
is falseprivate void handleSERVERPING(StringConnection c, SOCServerPing mes)
SOCMessage.SERVERPING
.
private void handleVERSION(StringConnection c, SOCVersion mes)
Along with the game list, the client will need to know the game option info.
This is sent when the client asks (after VERSION) for GAMEOPTIONGETINFOS
.
c
- the connection that sent the messagemes
- the messageboolean setClientVersSendGamesOrReject(StringConnection c, int cvers, java.lang.String clocale, boolean isKnown)
CLI_VERSION_MIN
.
If version is too low, send REJECTCONNECTION
.
If we haven't yet sent the game list, send now.
If we've already sent the game list, send changes based on true version.
Along with the game list, the client will need to know the game option info.
This is sent when the client asks (after VERSION) for GAMEOPTIONGETINFOS
.
Game options are sent after client version is known, so the list of
sent options is based on client version.
I18N: If client doesn't send a locale string, the default locale en_US
is used.
Robot clients will get the default locale and localeStr here, those will be cleared soon in
handleIMAROBOT(StringConnection, SOCImARobot)
.
Locks: To set the version, will synchronize briefly on unnamedConns
.
If c.getVersion()
is already == cvers,
don't bother to lock and set it.
Package access (not private) is strictly for use of SOCClientData.SOCCDCliVersionTask.run()
.
c
- Client's connectioncvers
- Version reported by client, or assumed version if no reportclocale
- Locale reported by client, or null if none given (was added to SOCVersion
in 2.0.00)isKnown
- Is this the client's definite version, or just an assumed one?
Affects c.isVersionKnown
.
Can set the client's known version only once; a second "known" call with
a different cvers will be rejected.
private void handleJOIN(StringConnection c, SOCJoin mes)
CLI_VERSION_ASSUMED_GUESS
), disconnect if too low.
Requested channel name must pass SOCMessage.isSingleLineAndSafe(String)
.
Channel name "*"
is also rejected to avoid conflicts with admin commands.
c
- the connection that sent the messagemes
- the messageprivate void handleLEAVE(StringConnection c, SOCLeave mes)
c
- the connection that sent the messagemes
- the messageprivate void handleIMAROBOT(StringConnection c, SOCImARobot mes)
SOCVersion
before sending this message.
Their version is checked here, must equal server's version.
For stability and control, the cookie in this message must
match this server's robotCookie
.
Bot tuning parameters are sent to the bot. Its SOCClientData.isRobot
flag is set. Its
SOCClientData.locale
is cleared, but not its StringConnection.setI18NStringManager(SOCStringManager, String)
.
Sometimes a bot disconnects and quickly reconnects. In that case
this method removes the disconnect/reconnect messages from
Server.cliConnDisconPrintsPending
so they won't be printed.
c
- the connection that sent the messagemes
- the messageprivate void handleGAMETEXTMSG(StringConnection c, SOCGameTextMsg gameTextMsgMes)
Some commands are unprivileged and can be run by any client:
processDebugCommand(StringConnection, String, String, String)
.
private void processDebugCommand_gameStats(StringConnection c, java.lang.String gaName, SOCGame gameData, boolean isCheckTime)
SOCGameHandler.sendGameStateOVER(SOCGame)
.
Before v1.1.20, this method was processDebugCommand_checktime(..)
.
c
- Client requesting the statsgaName
- gameData.getName()
gameData
- Game to print statsisCheckTime
- True if called from *CHECKTIME* server command, false for *STATS*.
If true, mark text as urgent when sending remaining time before game expires.private void processDebugCommand_who(StringConnection c, SOCGame ga, java.lang.String cmdText)
*WHO*
to show members of current game,
or privileged *WHO* gameName|all|*
to show all connected clients or some other game's members.
Locks: Takes/releases gameList.takeMonitorForGame(gaName)
to call SOCGameListAtServer.getMembers(String)
.
c
- Client sending the *WHO* commandga
- Game in which the command was sentcmdText
- Text of *WHO* commandprivate void handleAUTHREQUEST(StringConnection c, SOCAuthRequest mes)
"authentication request"
message.
Sent by clients since v1.1.19 before creating a game or when connecting using SOCAccountClient
.
If c.getData()
!= null
, the client already authenticated and
this method replies with SOCStatusMessage.SV_OK
without checking the password in this message.
c
- the connection that sent the messagemes
- the messageisUserDBUserAdmin(String, boolean)
private void handleJOINGAME(StringConnection c, SOCJoinGame mes)
If client hasn't yet sent its version, assume is version 1.0.00 (CLI_VERSION_ASSUMED_GUESS
), disconnect if too low.
If the client is too old to join a specific game, return a STATUSMESSAGE. (since 1.1.06)
c
- the connection that sent the messagemes
- the messageprivate void createOrJoinGameIfUserOK(StringConnection c, java.lang.String msgUser, java.lang.String msgPass, java.lang.String gameName, java.util.Map<java.lang.String,SOCGameOption> gameOpts)
Game name and player name have a maximum length and some disallowed characters; see parameters.
Check the client's SOCClientData.getCurrentCreatedGames()
vs CLIENT_MAX_CREATE_GAMES
.
If client is replacing/taking over their own lost connection, first tell them they're rejoining all their other games. That way, the requested game's window will appear last, not hidden behind the others.
Process if gameOpts != null:
SV_NEWGAME_ALREADY_EXISTS
)
SV_NEWGAME_OPTION_UNKNOWN
) SV_NEWGAME_OPTION_VALUE_TOONEW
) SOCGameOption.adjustOptionsToKnown(Map, Map, boolean)
.
GameHandler.joinGame(SOCGame, StringConnection, boolean, boolean)
GameHandler.joinGame(SOCGame, StringConnection, boolean, boolean)
-- If the game is already in progress, this will include all pieces on the board, and the rest of game state.
c
- connection requesting the game, must not be nullmsgUser
- username of client in message. Must pass SOCMessage.isSingleLineAndSafe(String)
and be at most PLAYER_NAME_MAX_LENGTH
characters.
Calls msgUser.trim()
before checking length.msgPass
- password of client in message; will be trim()med
.gameName
- name of game to create/join. Must pass SOCMessage.isSingleLineAndSafe(String)
and be at most GAME_NAME_MAX_LENGTH
characters.
Calls gameName.trim()
before checking length.
Game name "*"
is also rejected to avoid conflicts with admin commands.gameOpts
- if game has options, contains SOCGameOption
to create new game; if not null, will not join an existing game.
Will validate and adjust by calling
SOCGameOption.adjustOptionsToKnown(Map, Map, boolean)
with doServerPreadjust true.private void startRobotOnlyGames(boolean hasGameListMonitor)
numRobotOnlyGamesRemaining
> 0.
Locks: May or may not have SOCGameList.takeMonitor()
when calling;
see hasGameListMonitor
parameter. If not already held, this method takes and releases that monitor.
hasGameListMonitor
- True if caller holds the SOCGameList.takeMonitor()
lock alreadyprivate void handleLEAVEGAME(StringConnection c, SOCLeaveGame mes)
c
- the connection that sent the messagemes
- the messageprivate void handleLEAVEGAME_member(StringConnection c, java.lang.String gaName)
handleLEAVEGAME(StringConnection, SOCLeaveGame)
.
private void handleLEAVEGAME_maybeGameReset_oldRobot(java.lang.String gaName)
handleLEAVEGAME(StringConnection, SOCLeaveGame)
.
Ignore the robot (since it's not a member of the game) unless
gamestate is SOCGame.READY_RESET_WAIT_ROBOT_DISMISS
.
private void handleSITDOWN(StringConnection c, SOCSitDown mes)
c
- the connection that sent the messagemes
- the messageprivate void handleSTARTGAME(StringConnection c, SOCStartGame mes, int botsOnly_maxBots)
Ask some robots
to fill
empty seats, or begin the game
if no robots needed.
Called when clients have sat at a new game and a client asks to start it, not called during game board reset.
For robot debugging, a client can start and observe a robots-only game if the
PROP_JSETTLERS_BOTS_BOTGAMES_TOTAL
property != 0 (including < 0).
c
- the connection that sent the messagemes
- the messagebotsOnly_maxBots
- For bot debugging, maximum number of bots to add to the game,
or 0 to fill all empty seats. This parameter is used only when requesting a new
robots-only game using the *STARTBOTGAME* debug command; ignored otherwise.private void readyGameAskRobotsJoin(SOCGame ga, StringConnection[] robotSeats, int maxBots) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
SOCGame.getAvailableSeatCount()
robots will
be asked.
Called by handleSTARTGAME
,
resetBoardAndNotify
.
Once the robots have all responded (from their own threads/clients) and joined up, the game can begin.
ga
- Game to ask robots to joinrobotSeats
- If robotSeats is null, robots are randomly selected.
If non-null, a MAXPLAYERS-sized array of StringConnections.
Any vacant non-locked seat, with index i,
is filled with the robot whose connection is robotSeats[i].
Other indexes should be null, and won't be used.maxBots
- Maximum number of bots to add, or 0 to fill all empty seats
java.lang.IllegalStateException
- if ga.gamestate
is not READY,
or if ga.version
is
somehow newer than server's version (which is assumed to be robots' version).
java.lang.IllegalArgumentException
- if robotSeats is not null but wrong length,
or if a robotSeat element is null but that seat wants a robot (vacant non-locked).void debug_printPieceDiceNumbers(SOCGame ga, java.lang.String message)
ga
- Game datamessage
- "no player gets anything" stringprivate boolean debug_printPieceDiceNumbers_pl(SOCPlayer pl, int roll, SOCBoard board, java.lang.String pieceType, java.util.Enumeration<? extends SOCPlayingPiece> pe)
SOCGame.getResourcesGainedFromRollPieces(int, soc.game.SOCResourceSet, soc.game.SOCResourceSet, int, java.util.Collection extends soc.game.SOCPlayingPiece>, int)
.
private void handleCHANGEFACE(StringConnection c, SOCChangeFace mes)
c
- the connectionmes
- the messageprivate void handleSETSEATLOCK(StringConnection c, SOCSetSeatLock mes)
c
- the connectionmes
- the messageprivate void handleRESETBOARDREQUEST(StringConnection c, SOCResetBoardRequest mes)
The requesting player doesn't vote, but server still sends the vote-request-message, to tell that client their request was accepted and voting has begun.
If only one player remains (all other humans have left at end), ask them to start a new game instead. This is a rare occurrence and we shouldn't bring in new robots and all, since we already have an interface to set up a game.
If any human player's client is too old to vote for reset, assume they vote yes.
c
- the connectionmes
- the messageresetBoardAndNotify(String, int)
private void handleRESETBOARDVOTE(StringConnection c, SOCResetBoardVote mes)
c
- the connectionmes
- the messageresetBoardAndNotify(String, int)
void resetBoardVoteNotifyOne(SOCGame ga, int pn, java.lang.String plName, boolean vyes)
ga
- Game for this reset votepn
- Player number who is votingplName
- Name of player who is votingvyes
- Player's vote, Yes or nopublic static final boolean clientHasLocalizedStrs_gameScenarios(StringConnection c)
SOCScenario
names and descriptions?
Checks these conditions:
c.scd.wantsI18N
flag is set:
Has locale, new-enough version, has requested I18N strings (see that flag's javadocs).
c.getLocalized
("gamescen.SC_WOND.n"
)
returns a string different than i18n_scenario_SC_WOND_desc
:
This checks whether a fallback is being used because the client's locale has no scenario strings
c
- Client connection
public static java.util.List<java.lang.String> localizeGameScenarios(java.util.Locale loc, java.util.Collection<java.lang.String> scKeys, boolean checkUnknowns_skipFirst, SOCClientData scd)
SOCScenario
s. Assumes client locale has scenario strings:
Call clientHasLocalizedStrs_gameScenarios(StringConnection)
before calling this method.
Fills and returns a list with each scKeys
key, scenario name, scenario description
from c.getLocalized("gamescen." + scKey + ".n")
and ("gamescen." + scKey + ".d")
.
loc
- Client's locale for StringManager i18n lookups. This is passed instead of the client connection
to simplify SOCPlayerClient's localizations before starting its practice server.scKeys
- Scenario keynames to localize, such as a List
of keynames or the Set
returned from SOCScenario.getAllKnownScenarioKeynames()
.
null
to use SOCScenario.getAllKnownScenarioKeynames()
.checkUnknowns_skipFirst
- Switch to allow calling this method from multiple places:
scKeys
has no unknown keys, will not call
SOCScenario.getScenario(String)
to verify them.
scKeys
could be SOCScenario.getAllKnownScenarioKeynames()
, for example.
The localized strings for each scKey are looked up and added to the list if found.
If any scKey
is missing localized string(s), that key won't be in the returned list.
scKeys
is a List
of keys from a client, and may have
scenario names unknown at this server version. Will ignore the first entry because in the
client message, the first list entry isn't a scenario key. Will call
SOCScenario.getScenario(String)
on each key to verify it exists. The localized strings
for each known scKey are looked up and added to the list. If the scenario is unknown or its
strings aren't localized, the key and SOCLocalizedStrings.MARKER_KEY_UNKNOWN
are added instead.
scd
- Optional client data to track which scenario strings are sent to client, or null
.
This method will update scd.scenariosInfoSent
.
checkUnknowns_skipFirst
, unknown scenarios have 2 consecutive entries
in the list: Key, SOCLocalizedStrings.MARKER_KEY_UNKNOWN
.private void handleLOCALIZEDSTRINGS(StringConnection c, SOCLocalizedStrings mes)
private void handleGAMEOPTIONGETDEFAULTS(StringConnection c, SOCGameOptionGetDefaults mes)
SOCGameOption
values.
Responds to client by sending GAMEOPTIONGETDEFAULTS
.
All of server's known options are sent, except empty string-valued options.
Depending on client version, server's response may include option names that
the client is too old to use; the client is able to ignore them.
If the client is older than SOCGameOption.VERSION_FOR_LONGER_OPTNAMES
,
options with long names won't be sent.
I18N: Since the New Game dialog will need localized strings for SOCScenario
s,
v2.0.00 sends those strings before the game option default values, so the client will have them
before showing the dialog.
c
- the connectionmes
- the messageprivate void handleGAMEOPTIONGETINFOS(StringConnection c, SOCGameOptionGetInfos mes)
GAMEOPTIONINFO
message per option keyname.
Mark the end of the option list with GAMEOPTIONINFO
("-").
If this list is empty, "-" will be the only GAMEOPTIONGETINFO message sent.
We check the default values, not current values, so the list is unaffected by
cases where some option values are restricted to newer client versions.
Any option where opt.minVersion
is too new for
this client's version, is sent as SOCGameOption.OTYPE_UNKNOWN
.
If the client is older than SOCGameOption.VERSION_FOR_LONGER_OPTNAMES
,
options with long names won't be sent.
c
- the connectionmes
- the messageprivate void handleSCENARIOINFO(StringConnection c, SOCScenarioInfo mes)
SOCScenario
info.
Added 2015-09-21 for v2.0.00.
void sendGameScenarioInfo(java.lang.String scKey, SOCScenario sc, StringConnection c, boolean stringsOnly)
Sends nothing if scKey
and sc
are both null.
Sends nothing if client's version is older than 2.0.00 (SOCScenario.VERSION_FOR_SCENARIOS
).
Will not send localized strings if locale is null.
Checks and updates the connection's SOCClientData.sentAllScenarioStrings
,
SOCClientData.sentAllScenarioInfo
, SOCClientData.scenariosInfoSent
and
related tracking fields.
Scenario's minVersion
isn't checked here; may send information
about a scenario that's too new for the client's version to join games with it.
scKey
- Scenario keyname, from
game.getGameOptionStringValue("SC")
, or null.
Sends nothing if scKey
and sc
are both null.sc
- Scenario data if known, or null to use
SOCScenario.getScenario(scKey)
.
When sc != null
, will always send a SOCScenarioInfo
message
even if SOCClientData.sentAllScenarioInfo
is set, unless client version is too old.c
- Client connectionstringsOnly
- If true, send only localized strings, not entire SOCScenarioInfo
.private void handleNEWGAMEWITHOPTIONSREQUEST(StringConnection c, SOCNewGameWithOptionsRequest mes)
createOrJoinGameIfUserOK(StringConnection, String, String, String, Map)
.
Because this message is sent only by clients newer than 1.1.06, we definitely know that the client has already sent its version information.
c
- the connectionmes
- the messageprivate void handleCREATEACCOUNT(StringConnection c, SOCCreateAccount mes)
c
- the connectionmes
- the messageprivate void joinGame(SOCGame gameData, StringConnection c, boolean isReset, boolean isTakingOver)
GameHandler.joinGame(SOCGame, StringConnection, boolean, boolean)
;
see that method's javadoc for details.
gameData
- Game to joinc
- The connection of joining clientisReset
- Game is a board-reset of an existing game; should always be false when server is calling,
board resets are up to the GameHandler.isTakingOver
- Client is re-joining; this connection replaces an earlier one which
is defunct because of a network problem.
If isTakingOver, don't send anything to other players.connectToGame(StringConnection, String, Map)
,
createOrJoinGameIfUserOK(StringConnection, String, String, String, Map)
private void sitDown(SOCGame ga, StringConnection c, int pn, boolean robot, boolean isReset)
Calls SOCGame.addPlayer(String, int)
. Announces with SOCSitDown
to all game members.
Sends sitting player their own data via GameHandler.sitDown_sendPrivateInfo(SOCGame, StringConnection, int)
.
If game is waiting for robots to join, and sitting player is the last bot, start the game.
ga
- the gamec
- the connection for the playerpn
- which seat the player is takingrobot
- true if this player is a robotisReset
- Game is a board-reset of an existing gameprivate void resetBoardAndNotify(java.lang.String gaName, int requestingPlayer)
resetBoardAndNotify_finish(SOCGameBoardReset, SOCGame)
.
SOCGame.READY_RESET_WAIT_ROBOT_DISMISS
.
SOCGame.boardResetOngoingInfo
.
Wait for them to leave the old game before continuing.
The call will be made from handleLEAVEGAME_maybeGameReset_oldRobot(String)
.
resetBoardAndNotify_finish(SOCGameBoardReset, SOCGame)
.
This ends this method. Step 3 and the rest are in
resetBoardAndNotify_finish(SOCGameBoardReset, SOCGame)
.
private void resetBoardAndNotify_finish(SOCGameBoardReset reBoard, SOCGame reGame)
resetBoardAndNotify(String, int)
,
after any robots have left the old game.
reBoard
- Board reset data, from SOCGameListAtServer.resetBoard(String)
or reGame.boardResetOngoingInfo
reGame
- The new game created by the reset, with gamestate NEW
or READY_RESET_WAIT_ROBOT_DISMISS
void gameOverIncrGamesFinishedCount()
SOCGame.OVER
(or higher)
from a lower/earlier state.
Thread-safe; synchronizes on an internal object.
Package-level access for calls from GameHandler
s.
protected void storeGameScores(SOCGame ga)
Does nothing unless property jsettlers.db.save.games
is true. (SOCDBHelper.PROP_JSETTLERS_DB_SAVE_GAMES
)
ga
- the game; state should be SOCGame.OVER
protected void recordGameEvent(java.lang.String gameName, java.lang.String event)
gameName
- the name of the gameevent
- the eventpublic void checkForExpiredGames(long currentTimeMillis)
SOCGame.isPractice
flag set) don't expire.
Is callback method every few minutes from SOCGameTimeoutChecker.run()
.
currentTimeMillis
- The time when called, from System.currentTimeMillis()
GAME_TIME_EXPIRE_WARN_MINUTES
,
checkForExpiredTurns(long)
public void checkForExpiredTurns(long currentTimeMillis)
SOCGame.lastActionTime
field, and calls
GameHandler.endTurnIfInactive(SOCGame, long)
if the
last action is older than ROBOT_FORCE_ENDTURN_SECONDS
.
Is callback method every few seconds from SOCGameTimeoutChecker.run()
.
currentTimeMillis
- The time when called, from System.currentTimeMillis()
ROBOT_FORCE_ENDTURN_SECONDS
,
checkForExpiredGames(long)
public static SOCGameOption parseCmdline_GameOption(SOCGameOption op, java.lang.String optRaw, java.util.HashMap<java.lang.String,java.lang.String> optsAlreadySet) throws java.lang.IllegalArgumentException
SOCGameOption.setKnownOptionCurrentValue(SOCGameOption)
.
Note that an unknown SOCScenario
name (value of game option "SC"
)
isn't treated as an error here; SC
's value will be set to the unknown scenario.
Code elsewhere will print an error and halt startup.
op
- Game option, as parsed by
SGO.parseOptionNameValue(optNameValue, true)
or
SGO.parseOptionNameValue(optkey, optval, true)
.
forceNameUpcase == true
.
null
is allowed and will throw
IllegalArgumentException("Unknown or malformed game option: " + optRaw)
.optRaw
- To include in exception text or a value into optsAlreadySet
,
the option name or name=value from command line. Should not be null.optsAlreadySet
- For tracking, game option names we've already encountered on the command line.
This method will add (optName
, optNameValue
) to this map.
Can be null
if not needed.
java.lang.IllegalArgumentException
- if bad name, bad value, or already set from command line.
Throwable.getMessage()
will have problem details:
SOCGameOption.parseOptionNameValue(String, boolean)
SOCGameOption.setKnownOptionCurrentValue(SOCGameOption)
optsAlreadySet
public static java.util.Properties parseCmdline_DashedArgs(java.lang.String[] args)
Checks first for the optional server startup properties file "jsserver.properties"
(SOC_SERVER_PROPS_FILENAME
).
If the file exists but there is an error reading it, calls System.exit(1)
to exit because currently only main(..)
calls this method.
For details on the java properties file syntax (#
starts a comment line, etc),
see Properties.load(java.io.InputStream)
.
If a property appears on the command line and also in jsserver.properties
,
the command line's value overrides the file's.
If any game options are set ("-o", "--option"), then
hasSetGameOptions
is set to true, and
SOCGameOption.setKnownOptionCurrentValue(SOCGameOption)
is called to set them globally.
If jsserver.properties
file contains game option properties (jsettlers.gameopt.*
),
they will be checked for possible problems:
jsettlers.gameopt.
prefix
parseCmdline_GameOption(SOCGameOption, String, HashMap)
PROP_JSETTLERS_GAMEOPT_PREFIX
for game option property syntax.
If args[] is empty, it will use defaults for
PROP_JSETTLERS_PORT
and PROP_JSETTLERS_CONNECTIONS
}.
Does not use a PROP_JSETTLERS_STARTROBOTS
default, that's
handled in initSocServer(String, String, Properties)
.
Sets hasStartupPrintAndExit
if appropriate.
args
- args as passed to main
PROP_JSETTLERS_PORT
,
PROP_JSETTLERS_CONNECTIONS
,
SOCDBHelper.PROP_JSETTLERS_DB_USER
,
SOCDBHelper.PROP_JSETTLERS_DB_PASS
.private static final void init_propsSetGameopts(java.util.Properties pr) throws java.lang.IllegalArgumentException
jsettlers.gameopt.*
server properties found.
Option keynames are case-insensitive past that prefix.
See PROP_JSETTLERS_GAMEOPT_PREFIX
for expected syntax.
Calls parseCmdline_GameOption(SOCGameOption, String, HashMap)
for each one found,
to set its current value in SOCGameOptions
's static set of known opts.
Note that an unknown SOCSscenario
name (value of game option "SC"
)
is not an error here; init_checkScenarioOpts(Map, boolean, String, String, String)
will check for that and its caller will halt startup if found.
pr
- Properties which may contain PROP_JSETTLERS_GAMEOPT_PREFIX
* entries
java.lang.IllegalArgumentException
- if any game option property has a bad name or value.
Throwable.getMessage()
will collect all option problems to 1 string, separated by "\n"
:
jsettlers.gameopt.
prefix
parseCmdline_GameOption(SOCGameOption, String, HashMap)
public static java.util.List<Triple> checkScenarioOpts(java.util.Map<?,?> opts, boolean optsAreProps, java.lang.String scName)
"SC"
),
check that the scenario is known and that its game options don't conflict with any others specified
in the properties or command line.
The scenario named in opts.get("SC")
or scName
is retrieved with
SOCScenario.getScenario(String)
; an empty scenario name "" is treated as an unknown scenario.
The scenario will be the default scenario, but its option values aren't set as default at server startup.
When a new game begins using that scenario, at that time scenario options override any other options
specified for the game (except whichever "VP"
is greater is kept). Since the user may specify
a different scenario, 'conflicting' options in opts
are only potentially a problem and will be
returned as a list for warnings (not errors) to be printed during server init.
opts
- Option name key and value strings, typically from command line or
properties file parsing. See optsIsFromProps
for format of opts
keys and values.optsAreProps
- If true, opts
keys and values are from the properties file:
key = PROP_JSETTLERS_GAMEOPT_PREFIX
+ optname, value = option value.
Option names are not case-sensitive but PROP_JSETTLERS_GAMEOPT_PREFIX
is.
scName
- Scenario name to check against, or null
to use value of opts.get("SC"
); never ""private static boolean init_checkScenarioOpts(java.util.Map<?,?> opts, boolean optsAreProps, java.lang.String srcDesc, java.lang.String scName, java.lang.String scNameSrcDesc)
checkScenarioOpts(Map, boolean, String)
and print any warnings it returns
to System.err
. An unknown scenario name is printed as an error not a warning.
An empty scenario name "" from opts.get("SC")
or scName
is treated as an unknown scenario.
opts
- Options to check, see checkScenarioOpts(Map, boolean, String)
optsAreProps
- Are opts
from properties or command line?
See checkScenarioOpts(Map, boolean, String)
.srcDesc
- Description of opts
for warning message text:
"Command line" or properties filename "jsserver.properties"scName
- Scenario name to check against, or null
to use value of opts.get("SC"
); never ""scNameSrcDesc
- If scName
isn't from opts
, lowercase description of its source
for warnings (like srcDesc
), otherwise null
.
If scNameSrcDesc != null
, will not print a warning if scName
is unknown, to avoid
repeating the warning already printed when that SC was checked while parsing its source.
"SC"
option, false if unknown.private void init_resetUserPassword(java.lang.String uname)
--pw-reset=username
,
prompt for and change that user's password.
If successful, sets getUtilityModeMessage()
to "The password was changed"
or similar; if unsuccessful (no db, user not found, etc), prints an error and
sets getUtilityModeMessage()
to null
.
uname
- Username to change passwordprivate void printAuditMessage(java.lang.String req, java.lang.String msg, java.lang.String obj, java.util.Date at, java.lang.String reqHost)
System.out
in a standard format.
obj
'
by 'req
' from reqHost
at at
req
' from reqHost
at at
req
- Requesting user, or null
if unknownmsg
- Message textobj
- Object affected by the action, or null
if noneat
- Timestamp, or null
to use current timereqHost
- Requester client's hostname, from StringConnection.host()
public static void printUsage(boolean longFormat)
longFormat
- short or long?
Long format gives details and also calls Version.printVersionText(java.io.PrintStream, String)
beforehand.
Short format is printed at most once, after checking printedUsageAlready
.public static void printGameOptions()
private static void clearBuffer(java.lang.StringBuilder sb)
StringBuilder.length()
.
sb
- StringBuilder to clearprivate static java.lang.StringBuilder readPassword(java.lang.String prompt)
This rudimentary method exists for compatability: java 1.5 doesn't have
System.console.readPassword()
, and the Eclipse console also
doesn't offer System.console
.
The input is not masked because there's no cross-platform way to do so in 1.5.
prompt
- Optional password prompt; default is "Password:"
clearBuffer(StringBuilder)
.
If ^C or an error occurs, returns null
.public static void main(java.lang.String[] args)
Checks for the optional server startup properties file "jsserver.properties"
,
and parses the command line for switches. If a property appears on the command line and
also in jsserver.properties
, the command line's value overrides the file's.
Creates and starts a SOCServer
via SOCServer(int, Properties)
.
If there are problems with the network setup,
or with running a db setup script
,
this method will call System.exit(1)
.
If a db setup script runs successfully,
this method will call System.exit(2)
.
args
- arguments: port number, etcprintUsage(boolean)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |