|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsoc.util.SOCGameList
soc.server.SOCGameListAtServer
public class SOCGameListAtServer
A class for creating and tracking the games;
contains each game's name, game options,
SOCGame object, and clients (StringConnections).
In 1.1.07, parent class SOCGameList was refactored, with
some methods moved to this new subclass, such as
createGame.
SOCBoardLargeAtServer| Nested Class Summary | |
|---|---|
protected static class |
SOCGameListAtServer.GameInfoAtServer
Game info including server-side information, such as the game type's GameHandler. |
| Nested classes/interfaces inherited from class soc.util.SOCGameList |
|---|
SOCGameList.GameInfo |
| Field Summary | |
|---|---|
static int |
GAME_TIME_EXPIRE_MINUTES
Number of minutes after which a game (created on the list) is expired. |
protected java.util.Hashtable<java.lang.String,java.util.Vector<StringConnection>> |
gameMembers
synchronized map of game names to Vector of game members ( StringConnections) |
| Fields inherited from class soc.util.SOCGameList |
|---|
gameData, gameInfo, inUse |
| Constructor Summary | |
|---|---|
SOCGameListAtServer()
constructor |
|
| Method Summary | |
|---|---|
void |
addMember(StringConnection conn,
java.lang.String gaName)
add a member to the game. |
SOCGame |
createGame(java.lang.String gaName,
java.lang.String gaOwner,
java.lang.String gaLocaleStr,
java.util.Map<java.lang.String,SOCGameOption> gaOpts,
GameHandler handler)
create a new game, and add to the list; game will expire in GAME_TIME_EXPIRE_MINUTES minutes. |
void |
deleteGame(java.lang.String gaName)
remove the game from the list and call SOCGame.destroyGame() via SOCGameList.deleteGame(String). |
GameHandler |
getGameTypeHandler(java.lang.String gaName)
Get this game's type handler from its SOCGameListAtServer.GameInfoAtServer. |
java.util.Vector<StringConnection> |
getMembers(java.lang.String gaName)
get a game's members (client connections) |
boolean |
isGameEmpty(java.lang.String gaName)
does the game have no members? |
boolean |
isMember(StringConnection conn,
java.lang.String gaName)
is this connection a member of the game? |
java.util.Vector<SOCGame> |
memberGames(StringConnection c,
java.lang.String firstGameName)
List of games containing this member. |
int |
playerGamesMinVersion(StringConnection plConn)
For the games this player is in, what's the minimum required client version? Checks SOCGame.getClientVersionMinRequired(). |
void |
removeMember(StringConnection conn,
java.lang.String gaName)
remove member from the game. |
void |
replaceMemberAllGames(StringConnection oldConn,
StringConnection newConn)
Replace member from all games, with a new connection with same name (after a network problem). |
SOCGameBoardReset |
resetBoard(java.lang.String gaName)
Reset the board of this game, create a new game of same name, same players, new layout. |
| Methods inherited from class soc.util.SOCGameList |
|---|
addGame, addGame, addGames, addGames, getGameData, getGameNames, getGameOptions, getGameOptionsString, getGamesData, isGame, isUnjoinableGame, parseGameOptions, releaseMonitor, releaseMonitorForGame, size, takeMonitor, takeMonitorForGame |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int GAME_TIME_EXPIRE_MINUTES
Before v2.0.00 this field was named GAME_EXPIRE_MINUTES.
createGame(String, String, String, Map, GameHandler),
SOCGame.setExpiration(long),
SOCServer.checkForExpiredGames(long)protected java.util.Hashtable<java.lang.String,java.util.Vector<StringConnection>> gameMembers
StringConnections)
| Constructor Detail |
|---|
public SOCGameListAtServer()
| Method Detail |
|---|
public boolean isGameEmpty(java.lang.String gaName)
gaName - the name of the game
public GameHandler getGameTypeHandler(java.lang.String gaName)
SOCGameListAtServer.GameInfoAtServer.
gaName - Game name
null if game unknown or its GameInfo doesn't have a handlerpublic java.util.Vector<StringConnection> getMembers(java.lang.String gaName)
gaName - game name
StringConnections
public boolean isMember(StringConnection conn,
java.lang.String gaName)
gaName - the name of the gameconn - the member's connection
public void addMember(StringConnection conn,
java.lang.String gaName)
SOCGameList.takeMonitorForGame(String) before calling this.
gaName - the name of the gameconn - the member's connection; version should already be set
public void removeMember(StringConnection conn,
java.lang.String gaName)
SOCGameList.takeMonitorForGame(String) before calling this.
gaName - the name of the gameconn - the member's connection
public void replaceMemberAllGames(StringConnection oldConn,
StringConnection newConn)
throws java.lang.IllegalArgumentException
oldConn - the member's old connectionnewConn - the member's new connection
java.lang.IllegalArgumentException - if oldConn's keyname (via getData())
differs from newConn's keynamememberGames(StringConnection, String)
public SOCGame createGame(java.lang.String gaName,
java.lang.String gaOwner,
java.lang.String gaLocaleStr,
java.util.Map<java.lang.String,SOCGameOption> gaOpts,
GameHandler handler)
throws java.lang.IllegalArgumentException
GAME_TIME_EXPIRE_MINUTES minutes.
If a game already exists (per SOCGameList.isGame(String)), do nothing.
gaName - the name of the gamegaOwner - the game owner/creator's player name, or null (added in 1.1.10)gaLocaleStr - the game creator's locale, to later set SOCGame.hasMultiLocales if needed (added in 2.0.00)gaOpts - if game has options, its SOCGameOptions; otherwise null.
Should already be validated, by calling
SOCGameOption.adjustOptionsToKnown(Map, Map, boolean)
with doServerPreadjust true.handler - Game type handler for this game
java.lang.IllegalArgumentException - if handler is nullpublic SOCGameBoardReset resetBoard(java.lang.String gaName)
Robots are not copied and
must re-join the game. (They're removed from the list of game members.)
If the game had robots, they must leave the old game before any players can
join the new game; the new game's SOCGame.boardResetOngoingInfo field
is set to the object returned by this method, and its gameState will be
SOCGame.READY_RESET_WAIT_ROBOT_DISMISS instead of SOCGame.NEW.
Locking: Takes game monitor. Copies old game. Adds reset-copy to gamelist. Destroys old game. Releases game monitor.
gaName - Name of game - If not found, do nothing. No monitor is taken.
SOCGame.resetAsCopy()public void deleteGame(java.lang.String gaName)
SOCGame.destroyGame() via SOCGameList.deleteGame(String).
deleteGame in class SOCGameListgaName - the name of the gamepublic int playerGamesMinVersion(StringConnection plConn)
SOCGame.getClientVersionMinRequired().
This method helps determine if a client's connection can be "taken over" after a network problem. It synchronizes on gameData.
plConn - the previous connection of the player, which might be taken over
SOCGame.getClientVersionMinRequired(),
or 0 if player isn't in any games.
public java.util.Vector<SOCGame> memberGames(StringConnection c,
java.lang.String firstGameName)
c - ConnectionfirstGameName - Game name that should be first element of list
(if newConn is a member of it), or null.
replaceMemberAllGames(StringConnection, StringConnection)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||