New service group world order. My enthusiasm for widening is being stretched.

git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@177 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
Michael Bayne
2007-02-11 01:37:46 +00:00
parent 61d8f478e1
commit 75b34c6bf6
16 changed files with 287 additions and 353 deletions
@@ -72,6 +72,12 @@ public class ClientController extends Controller
return false;
}
// documentation inherited
public void clientWillLogon (Client client)
{
// nada
}
// documentation inherited
public void clientDidLogon (Client client)
{
@@ -148,6 +148,12 @@ public class LogonPanel extends JPanel
}
}
// documentation inherited from interface
public void clientWillLogon (Client client)
{
// nada
}
// documentation inherited from interface
public void clientDidLogon (Client client)
{
@@ -164,6 +170,7 @@ public class LogonPanel extends JPanel
// documentation inherited from interface
public void clientDidClear (Client client)
{
// nada
}
// documentation inherited from interface
@@ -26,6 +26,7 @@ import com.samskivert.util.*;
import com.threerings.util.StreamableArrayList;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationCodes;
import com.threerings.presents.server.InvocationManager;
import com.threerings.crowd.data.BodyObject;
@@ -37,13 +38,12 @@ import com.threerings.micasa.server.MiCasaConfig;
import com.threerings.micasa.server.MiCasaServer;
/**
* The lobby registry is the primary class that coordinates the lobby
* services on the client. It sets up the necessary invocation services
* and keeps track of the lobbies in operation on the server. Only one
* lobby registry should be created on a server.
* The lobby registry is the primary class that coordinates the lobby services on the client. It
* sets up the necessary invocation services and keeps track of the lobbies in operation on the
* server. Only one lobby registry should be created on a server.
*
* <p> Presently, the lobby registry is configured with lobbies via the
* server configuration. An example configuration follows:
* <p> Presently, the lobby registry is configured with lobbies via the server configuration. An
* example configuration follows:
*
* <pre>
* lobby_ids = foolobby, barlobby, bazlobby
@@ -60,16 +60,13 @@ import com.threerings.micasa.server.MiCasaServer;
* ...
* </pre>
*
* This information will be loaded from the MiCasa server configuration
* which means that it should live in
* <code>rsrc/config/micasa/server.properties</code> somwhere in the
* classpath where it will override the default MiCasa server properties
* file.
* This information will be loaded from the MiCasa server configuration which means that it should
* live in <code>rsrc/config/micasa/server.properties</code> somwhere in the classpath where it
* will override the default MiCasa server properties file.
*
* <p> The <code>UGI</code> or universal game identifier is a string that
* is used to uniquely identify every type of game and also to classify it
* according to meaningful keywords. It is best described with a few
* examples:
* <p> The <code>UGI</code> or universal game identifier is a string that is used to uniquely
* identify every type of game and also to classify it according to meaningful keywords. It is best
* described with a few examples:
*
* <pre>
* backgammon,board,strategy
@@ -77,29 +74,28 @@ import com.threerings.micasa.server.MiCasaServer;
* yahtzee,dice
* </pre>
*
* As you can see, a UGI should start with an identifier uniquely
* identifying the type of game and can be followed by a list of keywords
* that classify it as a member of a particular category of games
* (eg. board, card, dice, partner game, strategy game). A game can belong
* to multiple categories.
* As you can see, a UGI should start with an identifier uniquely identifying the type of game and
* can be followed by a list of keywords that classify it as a member of a particular category of
* games (eg. board, card, dice, partner game, strategy game). A game can belong to multiple
* categories.
*
* <p> As long as the UGIs in use by a particular server make some kind of
* sense, the client will be able to use them to search for lobbies
* containing games of similar types using the provided facilities.
* <p> As long as the UGIs in use by a particular server make some kind of sense, the client will
* be able to use them to search for lobbies containing games of similar types using the provided
* facilities.
*/
public class LobbyRegistry
implements LobbyProvider
{
/**
* Initializes the registry. It will use the supplied configuration
* instance to determine which lobbies to load, etc.
* Initializes the registry. It will use the supplied configuration instance to determine which
* lobbies to load, etc.
*
* @param invmgr a reference to the server's invocation manager.
*/
public void init (InvocationManager invmgr)
{
// register ourselves as an invocation service handler
invmgr.registerDispatcher(new LobbyDispatcher(this), true);
invmgr.registerDispatcher(new LobbyDispatcher(this), InvocationCodes.GLOBAL_GROUP);
// create our lobby managers
String[] lmgrs = null;
@@ -124,8 +120,8 @@ public class LobbyRegistry
}
/**
* Extracts the properties for a lobby from the server config and
* creates and initializes the lobby manager.
* Extracts the properties for a lobby from the server config and creates and initializes the
* lobby manager.
*/
protected void loadLobby (String lobbyId)
{
@@ -136,42 +132,33 @@ public class LobbyRegistry
// get the lobby manager class and UGI
String cfgClass = props.getProperty("config");
if (StringUtil.isBlank(cfgClass)) {
throw new Exception("Missing 'config' definition in " +
"lobby configuration.");
throw new Exception("Missing 'config' definition in lobby configuration.");
}
// create and initialize the lobby config object
LobbyConfig config = (LobbyConfig)
Class.forName(cfgClass).newInstance();
LobbyConfig config = (LobbyConfig)Class.forName(cfgClass).newInstance();
config.init(props);
// create and initialize the lobby manager. it will call
// lobbyReady() when it has obtained a reference to its lobby
// object and is ready to roll
LobbyManager lobmgr = (LobbyManager)
MiCasaServer.plreg.createPlace(config);
// create and initialize the lobby manager. it will call lobbyReady() when it has
// obtained a reference to its lobby object and is ready to roll
LobbyManager lobmgr = (LobbyManager)MiCasaServer.plreg.createPlace(config);
lobmgr.init(this, props);
} catch (Exception e) {
Log.warning("Unable to create lobby manager " +
"[lobbyId=" + lobbyId + ", error=" + e + "].");
Log.warning("Unable to create lobby manager [lobbyId=" + lobbyId +
", error=" + e + "].");
}
}
/**
* Returns information about all lobbies hosting games in the
* specified category.
* Returns information about all lobbies hosting games in the specified category.
*
* @param requester the body object of the client requesting the lobby
* list (which can be used to filter the list based on their
* capabilities).
* @param category the category of game for which the lobbies are
* desired.
* @param target the list into which the matching lobbies will be
* deposited.
* @param requester the body object of the client requesting the lobby list (which can be used
* to filter the list based on their capabilities).
* @param category the category of game for which the lobbies are desired.
* @param target the list into which the matching lobbies will be deposited.
*/
public void getLobbies (BodyObject requester, String category,
List target)
public void getLobbies (BodyObject requester, String category, List target)
{
ArrayList list = (ArrayList)_lobbies.get(category);
if (list != null) {
@@ -180,18 +167,16 @@ public class LobbyRegistry
}
/**
* Returns an array containing the category identifiers of all the
* categories in which lobbies have been registered with the registry.
* Returns an array containing the category identifiers of all the categories in which lobbies
* have been registered with the registry.
*
* @param requester the body object of the client requesting the
* cateogory list (which can be used to filter the list based on their
* capabilities).
* @param requester the body object of the client requesting the cateogory list (which can be
* used to filter the list based on their capabilities).
*/
public String[] getCategories (BodyObject requester)
{
// might want to cache this some day so that we don't recreate it
// every time someone wants it. we can cache the array until the
// category count changes
// might want to cache this some day so that we don't recreate it every time someone wants
// it. we can cache the array until the category count changes
String[] cats = new String[_lobbies.size()];
Iterator iter = _lobbies.keySet().iterator();
for (int i = 0; iter.hasNext(); i++) {
@@ -201,8 +186,8 @@ public class LobbyRegistry
}
/**
* Processes a request by the client to obtain a list of the lobby
* categories available on this server.
* Processes a request by the client to obtain a list of the lobby categories available on this
* server.
*/
public void getCategories (ClientObject caller, CategoriesListener listener)
{
@@ -210,11 +195,10 @@ public class LobbyRegistry
}
/**
* Processes a request by the client to obtain a list of lobbies
* matching the supplied category string.
* Processes a request by the client to obtain a list of lobbies matching the supplied category
* string.
*/
public void getLobbies (ClientObject caller, String category,
LobbiesListener listener)
public void getLobbies (ClientObject caller, String category, LobbiesListener listener)
{
StreamableArrayList target = new StreamableArrayList();
ArrayList list = (ArrayList)_lobbies.get(category);
@@ -225,16 +209,15 @@ public class LobbyRegistry
}
/**
* Called by our lobby managers once they have started up and are
* ready to do their lobby duties.
* Called by our lobby managers once they have started up and are ready to do their lobby
* duties.
*/
protected void lobbyReady (int placeOid, String gameIdent, String name)
{
// create a lobby record
Lobby record = new Lobby(placeOid, gameIdent, name);
// if we don't already have a default lobby, this one is the big
// winner
// if we don't already have a default lobby, this one is the big winner
if (_defLobbyOid == -1) {
_defLobbyOid = placeOid;
}
@@ -256,12 +239,11 @@ public class LobbyRegistry
_lobbies.put(category, catlist);
}
catlist.add(record);
Log.info("Registered lobby [cat=" + category +
", record=" + record + "].");
Log.info("Registered lobby [cat=" + category + ", record=" + record + "].");
}
/** A table containing references to all of our lobby records (in the
* form of category lists. */
/** A table containing references to all of our lobby records (in the form of category
* lists. */
protected HashMap _lobbies = new HashMap();
/** The oid of the default lobby. */
@@ -77,6 +77,12 @@ public class SimulatorController extends Controller
return false;
}
// documentation inherited
public void clientWillLogon (Client client)
{
// nada
}
// documentation inherited
public void clientDidLogon (Client client)
{
@@ -26,6 +26,7 @@ import java.util.ArrayList;
import com.threerings.util.Name;
import com.threerings.presents.data.ClientObject;
import com.threerings.presents.data.InvocationCodes;
import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.ClientManager;
import com.threerings.presents.server.ClientResolutionListener;
@@ -44,26 +45,23 @@ import com.threerings.parlor.game.server.GameManager;
import com.threerings.micasa.Log;
/**
* The simulator manager is responsible for handling the simulator
* services on the server side.
* The simulator manager is responsible for handling the simulator services on the server side.
*/
public class SimulatorManager
{
/**
* Initializes the simulator manager manager. This should be called by
* the server that is making use of the simulator services on the
* single instance of simulator manager that it has created.
* Initializes the simulator manager manager. This should be called by the server that is
* making use of the simulator services on the single instance of simulator manager that it has
* created.
*
* @param invmgr a reference to the invocation manager in use by this
* server.
* @param invmgr a reference to the invocation manager in use by this server.
*/
public void init (InvocationManager invmgr, PlaceRegistry plreg,
ClientManager clmgr, RootDObjectManager omgr,
SimulatorServer simserv)
public void init (InvocationManager invmgr, PlaceRegistry plreg, ClientManager clmgr,
RootDObjectManager omgr, SimulatorServer simserv)
{
// register our simulator provider
SimulatorProvider sprov = new SimulatorProvider(this);
invmgr.registerDispatcher(new SimulatorDispatcher(sprov), true);
invmgr.registerDispatcher(new SimulatorDispatcher(sprov), InvocationCodes.GLOBAL_GROUP);
// keep these for later
_plreg = plreg;
@@ -73,20 +71,18 @@ public class SimulatorManager
}
/**
* Creates a game along with the specified number of simulant players
* and forcibly moves all players into the game room.
* Creates a game along with the specified number of simulant players and forcibly moves all
* players into the game room.
*/
public void createGame (
BodyObject source, GameConfig config, String simClass, int playerCount)
public void createGame (BodyObject source, GameConfig config, String simClass, int playerCount)
{
new CreateGameTask(source, config, simClass, playerCount);
}
public class CreateGameTask
{
public CreateGameTask (
BodyObject source, GameConfig config, String simClass,
int playerCount)
public CreateGameTask (BodyObject source, GameConfig config, String simClass,
int playerCount)
{
// save off game request info
_source = source;
@@ -95,9 +91,8 @@ public class SimulatorManager
_playerCount = playerCount;
try {
// create the game manager and begin its initialization
// process. the game manager will take care of notifying the
// players that the game has been created
// create the game manager and begin its initialization process. the game manager
// will take care of notifying the players that the game has been created
// configure the game config with the player names
config.players = new Name[_playerCount];
@@ -141,8 +136,7 @@ public class SimulatorManager
}
}
public void resolutionFailed (Name username, Exception cause) {
Log.warning("Unable to create simulant body object " +
"[error=" + cause + "].");
Log.warning("Unable to create simulant body object [error=" + cause + "].");
}
};
@@ -154,8 +148,8 @@ public class SimulatorManager
}
/**
* Called when all simulant body objects are present and the
* simulants are ready to be created.
* Called when all simulant body objects are present and the simulants are ready to be
* created.
*/
protected void createSimulants ()
{
@@ -178,8 +172,8 @@ public class SimulatorManager
// give the simulant a chance to engage in place antics
sim.willEnterPlace(_gobj);
// move the simulant into the game room since they have no
// location director to move them automagically
// move the simulant into the game room since they have no location director to
// move them automagically
try {
_plreg.locprov.moveTo(bobj, _gobj.getOid());
} catch (Exception e) {