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:
@@ -423,10 +423,8 @@ public class EZGameManager extends GameManager
|
|||||||
super.didStartup();
|
super.didStartup();
|
||||||
|
|
||||||
_gameObj = (EZGameObject) _plobj;
|
_gameObj = (EZGameObject) _plobj;
|
||||||
|
|
||||||
_gameObj.setEzGameService(
|
_gameObj.setEzGameService(
|
||||||
(EZGameMarshaller) CrowdServer.invmgr.registerDispatcher(
|
(EZGameMarshaller) CrowdServer.invmgr.registerDispatcher(new EZGameDispatcher(this)));
|
||||||
new EZGameDispatcher(this), false));
|
|
||||||
|
|
||||||
if (isPartyGame()) {
|
if (isPartyGame()) {
|
||||||
startGame();
|
startGame();
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ public class ClientController extends Controller
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void clientWillLogon (Client client)
|
||||||
|
{
|
||||||
|
// nada
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void clientDidLogon (Client client)
|
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
|
// documentation inherited from interface
|
||||||
public void clientDidLogon (Client client)
|
public void clientDidLogon (Client client)
|
||||||
{
|
{
|
||||||
@@ -164,6 +170,7 @@ public class LogonPanel extends JPanel
|
|||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void clientDidClear (Client client)
|
public void clientDidClear (Client client)
|
||||||
{
|
{
|
||||||
|
// nada
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.samskivert.util.*;
|
|||||||
import com.threerings.util.StreamableArrayList;
|
import com.threerings.util.StreamableArrayList;
|
||||||
|
|
||||||
import com.threerings.presents.data.ClientObject;
|
import com.threerings.presents.data.ClientObject;
|
||||||
|
import com.threerings.presents.data.InvocationCodes;
|
||||||
import com.threerings.presents.server.InvocationManager;
|
import com.threerings.presents.server.InvocationManager;
|
||||||
|
|
||||||
import com.threerings.crowd.data.BodyObject;
|
import com.threerings.crowd.data.BodyObject;
|
||||||
@@ -37,13 +38,12 @@ import com.threerings.micasa.server.MiCasaConfig;
|
|||||||
import com.threerings.micasa.server.MiCasaServer;
|
import com.threerings.micasa.server.MiCasaServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The lobby registry is the primary class that coordinates the lobby
|
* The lobby registry is the primary class that coordinates the lobby services on the client. It
|
||||||
* services on the client. It sets up the necessary invocation services
|
* sets up the necessary invocation services and keeps track of the lobbies in operation on the
|
||||||
* and keeps track of the lobbies in operation on the server. Only one
|
* server. Only one lobby registry should be created on a server.
|
||||||
* lobby registry should be created on a server.
|
|
||||||
*
|
*
|
||||||
* <p> Presently, the lobby registry is configured with lobbies via the
|
* <p> Presently, the lobby registry is configured with lobbies via the server configuration. An
|
||||||
* server configuration. An example configuration follows:
|
* example configuration follows:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* lobby_ids = foolobby, barlobby, bazlobby
|
* lobby_ids = foolobby, barlobby, bazlobby
|
||||||
@@ -60,16 +60,13 @@ import com.threerings.micasa.server.MiCasaServer;
|
|||||||
* ...
|
* ...
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* This information will be loaded from the MiCasa server configuration
|
* This information will be loaded from the MiCasa server configuration which means that it should
|
||||||
* which means that it should live in
|
* live in <code>rsrc/config/micasa/server.properties</code> somwhere in the classpath where it
|
||||||
* <code>rsrc/config/micasa/server.properties</code> somwhere in the
|
* will override the default MiCasa server properties file.
|
||||||
* classpath where it will override the default MiCasa server properties
|
|
||||||
* file.
|
|
||||||
*
|
*
|
||||||
* <p> The <code>UGI</code> or universal game identifier is a string that
|
* <p> The <code>UGI</code> or universal game identifier is a string that is used to uniquely
|
||||||
* is used to uniquely identify every type of game and also to classify it
|
* identify every type of game and also to classify it according to meaningful keywords. It is best
|
||||||
* according to meaningful keywords. It is best described with a few
|
* described with a few examples:
|
||||||
* examples:
|
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* backgammon,board,strategy
|
* backgammon,board,strategy
|
||||||
@@ -77,29 +74,28 @@ import com.threerings.micasa.server.MiCasaServer;
|
|||||||
* yahtzee,dice
|
* yahtzee,dice
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* As you can see, a UGI should start with an identifier uniquely
|
* As you can see, a UGI should start with an identifier uniquely identifying the type of game and
|
||||||
* identifying the type of game and can be followed by a list of keywords
|
* can be followed by a list of keywords that classify it as a member of a particular category of
|
||||||
* that classify it as a member of a particular category of games
|
* games (eg. board, card, dice, partner game, strategy game). A game can belong to multiple
|
||||||
* (eg. board, card, dice, partner game, strategy game). A game can belong
|
* categories.
|
||||||
* to multiple categories.
|
|
||||||
*
|
*
|
||||||
* <p> As long as the UGIs in use by a particular server make some kind of
|
* <p> As long as the UGIs in use by a particular server make some kind of sense, the client will
|
||||||
* sense, the client will be able to use them to search for lobbies
|
* be able to use them to search for lobbies containing games of similar types using the provided
|
||||||
* containing games of similar types using the provided facilities.
|
* facilities.
|
||||||
*/
|
*/
|
||||||
public class LobbyRegistry
|
public class LobbyRegistry
|
||||||
implements LobbyProvider
|
implements LobbyProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initializes the registry. It will use the supplied configuration
|
* Initializes the registry. It will use the supplied configuration instance to determine which
|
||||||
* instance to determine which lobbies to load, etc.
|
* lobbies to load, etc.
|
||||||
*
|
*
|
||||||
* @param invmgr a reference to the server's invocation manager.
|
* @param invmgr a reference to the server's invocation manager.
|
||||||
*/
|
*/
|
||||||
public void init (InvocationManager invmgr)
|
public void init (InvocationManager invmgr)
|
||||||
{
|
{
|
||||||
// register ourselves as an invocation service handler
|
// 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
|
// create our lobby managers
|
||||||
String[] lmgrs = null;
|
String[] lmgrs = null;
|
||||||
@@ -124,8 +120,8 @@ public class LobbyRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extracts the properties for a lobby from the server config and
|
* Extracts the properties for a lobby from the server config and creates and initializes the
|
||||||
* creates and initializes the lobby manager.
|
* lobby manager.
|
||||||
*/
|
*/
|
||||||
protected void loadLobby (String lobbyId)
|
protected void loadLobby (String lobbyId)
|
||||||
{
|
{
|
||||||
@@ -136,42 +132,33 @@ public class LobbyRegistry
|
|||||||
// get the lobby manager class and UGI
|
// get the lobby manager class and UGI
|
||||||
String cfgClass = props.getProperty("config");
|
String cfgClass = props.getProperty("config");
|
||||||
if (StringUtil.isBlank(cfgClass)) {
|
if (StringUtil.isBlank(cfgClass)) {
|
||||||
throw new Exception("Missing 'config' definition in " +
|
throw new Exception("Missing 'config' definition in lobby configuration.");
|
||||||
"lobby configuration.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create and initialize the lobby config object
|
// create and initialize the lobby config object
|
||||||
LobbyConfig config = (LobbyConfig)
|
LobbyConfig config = (LobbyConfig)Class.forName(cfgClass).newInstance();
|
||||||
Class.forName(cfgClass).newInstance();
|
|
||||||
config.init(props);
|
config.init(props);
|
||||||
|
|
||||||
// create and initialize the lobby manager. it will call
|
// create and initialize the lobby manager. it will call lobbyReady() when it has
|
||||||
// lobbyReady() when it has obtained a reference to its lobby
|
// obtained a reference to its lobby object and is ready to roll
|
||||||
// object and is ready to roll
|
LobbyManager lobmgr = (LobbyManager)MiCasaServer.plreg.createPlace(config);
|
||||||
LobbyManager lobmgr = (LobbyManager)
|
|
||||||
MiCasaServer.plreg.createPlace(config);
|
|
||||||
lobmgr.init(this, props);
|
lobmgr.init(this, props);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Unable to create lobby manager " +
|
Log.warning("Unable to create lobby manager [lobbyId=" + lobbyId +
|
||||||
"[lobbyId=" + lobbyId + ", error=" + e + "].");
|
", error=" + e + "].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns information about all lobbies hosting games in the
|
* Returns information about all lobbies hosting games in the specified category.
|
||||||
* specified category.
|
|
||||||
*
|
*
|
||||||
* @param requester the body object of the client requesting the lobby
|
* @param requester the body object of the client requesting the lobby list (which can be used
|
||||||
* list (which can be used to filter the list based on their
|
* to filter the list based on their capabilities).
|
||||||
* capabilities).
|
* @param category the category of game for which the lobbies are desired.
|
||||||
* @param category the category of game for which the lobbies are
|
* @param target the list into which the matching lobbies will be deposited.
|
||||||
* desired.
|
|
||||||
* @param target the list into which the matching lobbies will be
|
|
||||||
* deposited.
|
|
||||||
*/
|
*/
|
||||||
public void getLobbies (BodyObject requester, String category,
|
public void getLobbies (BodyObject requester, String category, List target)
|
||||||
List target)
|
|
||||||
{
|
{
|
||||||
ArrayList list = (ArrayList)_lobbies.get(category);
|
ArrayList list = (ArrayList)_lobbies.get(category);
|
||||||
if (list != null) {
|
if (list != null) {
|
||||||
@@ -180,18 +167,16 @@ public class LobbyRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array containing the category identifiers of all the
|
* Returns an array containing the category identifiers of all the categories in which lobbies
|
||||||
* categories in which lobbies have been registered with the registry.
|
* have been registered with the registry.
|
||||||
*
|
*
|
||||||
* @param requester the body object of the client requesting the
|
* @param requester the body object of the client requesting the cateogory list (which can be
|
||||||
* cateogory list (which can be used to filter the list based on their
|
* used to filter the list based on their capabilities).
|
||||||
* capabilities).
|
|
||||||
*/
|
*/
|
||||||
public String[] getCategories (BodyObject requester)
|
public String[] getCategories (BodyObject requester)
|
||||||
{
|
{
|
||||||
// might want to cache this some day so that we don't recreate it
|
// might want to cache this some day so that we don't recreate it every time someone wants
|
||||||
// every time someone wants it. we can cache the array until the
|
// it. we can cache the array until the category count changes
|
||||||
// category count changes
|
|
||||||
String[] cats = new String[_lobbies.size()];
|
String[] cats = new String[_lobbies.size()];
|
||||||
Iterator iter = _lobbies.keySet().iterator();
|
Iterator iter = _lobbies.keySet().iterator();
|
||||||
for (int i = 0; iter.hasNext(); i++) {
|
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
|
* Processes a request by the client to obtain a list of the lobby categories available on this
|
||||||
* categories available on this server.
|
* server.
|
||||||
*/
|
*/
|
||||||
public void getCategories (ClientObject caller, CategoriesListener listener)
|
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
|
* Processes a request by the client to obtain a list of lobbies matching the supplied category
|
||||||
* matching the supplied category string.
|
* string.
|
||||||
*/
|
*/
|
||||||
public void getLobbies (ClientObject caller, String category,
|
public void getLobbies (ClientObject caller, String category, LobbiesListener listener)
|
||||||
LobbiesListener listener)
|
|
||||||
{
|
{
|
||||||
StreamableArrayList target = new StreamableArrayList();
|
StreamableArrayList target = new StreamableArrayList();
|
||||||
ArrayList list = (ArrayList)_lobbies.get(category);
|
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
|
* Called by our lobby managers once they have started up and are ready to do their lobby
|
||||||
* ready to do their lobby duties.
|
* duties.
|
||||||
*/
|
*/
|
||||||
protected void lobbyReady (int placeOid, String gameIdent, String name)
|
protected void lobbyReady (int placeOid, String gameIdent, String name)
|
||||||
{
|
{
|
||||||
// create a lobby record
|
// create a lobby record
|
||||||
Lobby record = new Lobby(placeOid, gameIdent, name);
|
Lobby record = new Lobby(placeOid, gameIdent, name);
|
||||||
|
|
||||||
// if we don't already have a default lobby, this one is the big
|
// if we don't already have a default lobby, this one is the big winner
|
||||||
// winner
|
|
||||||
if (_defLobbyOid == -1) {
|
if (_defLobbyOid == -1) {
|
||||||
_defLobbyOid = placeOid;
|
_defLobbyOid = placeOid;
|
||||||
}
|
}
|
||||||
@@ -256,12 +239,11 @@ public class LobbyRegistry
|
|||||||
_lobbies.put(category, catlist);
|
_lobbies.put(category, catlist);
|
||||||
}
|
}
|
||||||
catlist.add(record);
|
catlist.add(record);
|
||||||
Log.info("Registered lobby [cat=" + category +
|
Log.info("Registered lobby [cat=" + category + ", record=" + record + "].");
|
||||||
", record=" + record + "].");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A table containing references to all of our lobby records (in the
|
/** A table containing references to all of our lobby records (in the form of category
|
||||||
* form of category lists. */
|
* lists. */
|
||||||
protected HashMap _lobbies = new HashMap();
|
protected HashMap _lobbies = new HashMap();
|
||||||
|
|
||||||
/** The oid of the default lobby. */
|
/** The oid of the default lobby. */
|
||||||
|
|||||||
@@ -77,6 +77,12 @@ public class SimulatorController extends Controller
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited
|
||||||
|
public void clientWillLogon (Client client)
|
||||||
|
{
|
||||||
|
// nada
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
public void clientDidLogon (Client client)
|
public void clientDidLogon (Client client)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import java.util.ArrayList;
|
|||||||
import com.threerings.util.Name;
|
import com.threerings.util.Name;
|
||||||
|
|
||||||
import com.threerings.presents.data.ClientObject;
|
import com.threerings.presents.data.ClientObject;
|
||||||
|
import com.threerings.presents.data.InvocationCodes;
|
||||||
import com.threerings.presents.dobj.RootDObjectManager;
|
import com.threerings.presents.dobj.RootDObjectManager;
|
||||||
import com.threerings.presents.server.ClientManager;
|
import com.threerings.presents.server.ClientManager;
|
||||||
import com.threerings.presents.server.ClientResolutionListener;
|
import com.threerings.presents.server.ClientResolutionListener;
|
||||||
@@ -44,26 +45,23 @@ import com.threerings.parlor.game.server.GameManager;
|
|||||||
import com.threerings.micasa.Log;
|
import com.threerings.micasa.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The simulator manager is responsible for handling the simulator
|
* The simulator manager is responsible for handling the simulator services on the server side.
|
||||||
* services on the server side.
|
|
||||||
*/
|
*/
|
||||||
public class SimulatorManager
|
public class SimulatorManager
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Initializes the simulator manager manager. This should be called by
|
* Initializes the simulator manager manager. This should be called by the server that is
|
||||||
* the server that is making use of the simulator services on the
|
* making use of the simulator services on the single instance of simulator manager that it has
|
||||||
* single instance of simulator manager that it has created.
|
* created.
|
||||||
*
|
*
|
||||||
* @param invmgr a reference to the invocation manager in use by this
|
* @param invmgr a reference to the invocation manager in use by this server.
|
||||||
* server.
|
|
||||||
*/
|
*/
|
||||||
public void init (InvocationManager invmgr, PlaceRegistry plreg,
|
public void init (InvocationManager invmgr, PlaceRegistry plreg, ClientManager clmgr,
|
||||||
ClientManager clmgr, RootDObjectManager omgr,
|
RootDObjectManager omgr, SimulatorServer simserv)
|
||||||
SimulatorServer simserv)
|
|
||||||
{
|
{
|
||||||
// register our simulator provider
|
// register our simulator provider
|
||||||
SimulatorProvider sprov = new SimulatorProvider(this);
|
SimulatorProvider sprov = new SimulatorProvider(this);
|
||||||
invmgr.registerDispatcher(new SimulatorDispatcher(sprov), true);
|
invmgr.registerDispatcher(new SimulatorDispatcher(sprov), InvocationCodes.GLOBAL_GROUP);
|
||||||
|
|
||||||
// keep these for later
|
// keep these for later
|
||||||
_plreg = plreg;
|
_plreg = plreg;
|
||||||
@@ -73,20 +71,18 @@ public class SimulatorManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a game along with the specified number of simulant players
|
* Creates a game along with the specified number of simulant players and forcibly moves all
|
||||||
* and forcibly moves all players into the game room.
|
* players into the game room.
|
||||||
*/
|
*/
|
||||||
public void createGame (
|
public void createGame (BodyObject source, GameConfig config, String simClass, int playerCount)
|
||||||
BodyObject source, GameConfig config, String simClass, int playerCount)
|
|
||||||
{
|
{
|
||||||
new CreateGameTask(source, config, simClass, playerCount);
|
new CreateGameTask(source, config, simClass, playerCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CreateGameTask
|
public class CreateGameTask
|
||||||
{
|
{
|
||||||
public CreateGameTask (
|
public CreateGameTask (BodyObject source, GameConfig config, String simClass,
|
||||||
BodyObject source, GameConfig config, String simClass,
|
int playerCount)
|
||||||
int playerCount)
|
|
||||||
{
|
{
|
||||||
// save off game request info
|
// save off game request info
|
||||||
_source = source;
|
_source = source;
|
||||||
@@ -95,9 +91,8 @@ public class SimulatorManager
|
|||||||
_playerCount = playerCount;
|
_playerCount = playerCount;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// create the game manager and begin its initialization
|
// create the game manager and begin its initialization process. the game manager
|
||||||
// process. the game manager will take care of notifying the
|
// will take care of notifying the players that the game has been created
|
||||||
// players that the game has been created
|
|
||||||
|
|
||||||
// configure the game config with the player names
|
// configure the game config with the player names
|
||||||
config.players = new Name[_playerCount];
|
config.players = new Name[_playerCount];
|
||||||
@@ -141,8 +136,7 @@ public class SimulatorManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void resolutionFailed (Name username, Exception cause) {
|
public void resolutionFailed (Name username, Exception cause) {
|
||||||
Log.warning("Unable to create simulant body object " +
|
Log.warning("Unable to create simulant body object [error=" + cause + "].");
|
||||||
"[error=" + cause + "].");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -154,8 +148,8 @@ public class SimulatorManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when all simulant body objects are present and the
|
* Called when all simulant body objects are present and the simulants are ready to be
|
||||||
* simulants are ready to be created.
|
* created.
|
||||||
*/
|
*/
|
||||||
protected void createSimulants ()
|
protected void createSimulants ()
|
||||||
{
|
{
|
||||||
@@ -178,8 +172,8 @@ public class SimulatorManager
|
|||||||
// give the simulant a chance to engage in place antics
|
// give the simulant a chance to engage in place antics
|
||||||
sim.willEnterPlace(_gobj);
|
sim.willEnterPlace(_gobj);
|
||||||
|
|
||||||
// move the simulant into the game room since they have no
|
// move the simulant into the game room since they have no location director to
|
||||||
// location director to move them automagically
|
// move them automagically
|
||||||
try {
|
try {
|
||||||
_plreg.locprov.moveTo(bobj, _gobj.getOid());
|
_plreg.locprov.moveTo(bobj, _gobj.getOid());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ public class TrickCardGameManagerDelegate extends TurnGameManagerDelegate
|
|||||||
|
|
||||||
_trickCardGame.setTrickCardGameService(
|
_trickCardGame.setTrickCardGameService(
|
||||||
(TrickCardGameMarshaller)PresentsServer.invmgr.registerDispatcher(
|
(TrickCardGameMarshaller)PresentsServer.invmgr.registerDispatcher(
|
||||||
new TrickCardGameDispatcher(this), false));
|
new TrickCardGameDispatcher(this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Documentation inherited.
|
// Documentation inherited.
|
||||||
|
|||||||
@@ -36,21 +36,19 @@ import com.threerings.parlor.game.data.GameConfig;
|
|||||||
import com.threerings.parlor.util.ParlorContext;
|
import com.threerings.parlor.util.ParlorContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parlor director manages the client side of the game configuration
|
* The parlor director manages the client side of the game configuration and matchmaking
|
||||||
* and matchmaking processes. It is also the entity that is listening for
|
* processes. It is also the entity that is listening for game start notifications which it then
|
||||||
* game start notifications which it then dispatches the client entity
|
* dispatches the client entity that will actually create and display the user interface for the
|
||||||
* that will actually create and display the user interface for the game
|
* game that started.
|
||||||
* that started.
|
|
||||||
*/
|
*/
|
||||||
public class ParlorDirector extends BasicDirector
|
public class ParlorDirector extends BasicDirector
|
||||||
implements ParlorCodes, ParlorReceiver
|
implements ParlorCodes, ParlorReceiver
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Constructs a parlor director and provides it with the parlor
|
* Constructs a parlor director and provides it with the parlor context that it can use to
|
||||||
* context that it can use to access the client services that it needs
|
* access the client services that it needs to provide its own services. Only one parlor
|
||||||
* to provide its own services. Only one parlor director should be
|
* director should be active in the client at one time and it should be made available via the
|
||||||
* active in the client at one time and it should be made available
|
* parlor context.
|
||||||
* via the parlor context.
|
|
||||||
*
|
*
|
||||||
* @param ctx the parlor context in use by the client.
|
* @param ctx the parlor context in use by the client.
|
||||||
*/
|
*/
|
||||||
@@ -59,16 +57,13 @@ public class ParlorDirector extends BasicDirector
|
|||||||
super(ctx);
|
super(ctx);
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
|
|
||||||
// register ourselves with the invocation director as a parlor
|
// register ourselves with the invocation director as a parlor notification receiver
|
||||||
// notification receiver
|
_ctx.getClient().getInvocationDirector().registerReceiver(new ParlorDecoder(this));
|
||||||
_ctx.getClient().getInvocationDirector().registerReceiver(
|
|
||||||
new ParlorDecoder(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the invitation handler, which is the entity that will be
|
* Sets the invitation handler, which is the entity that will be notified when we receive
|
||||||
* notified when we receive incoming invitation notifications and when
|
* incoming invitation notifications and when invitations have been cancelled.
|
||||||
* invitations have been cancelled.
|
|
||||||
*
|
*
|
||||||
* @param handler our new invitation handler.
|
* @param handler our new invitation handler.
|
||||||
*/
|
*/
|
||||||
@@ -78,8 +73,8 @@ public class ParlorDirector extends BasicDirector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the specified observer to the list of entities that are
|
* Adds the specified observer to the list of entities that are notified when we receive a game
|
||||||
* notified when we receive a game ready notification.
|
* ready notification.
|
||||||
*/
|
*/
|
||||||
public void addGameReadyObserver (GameReadyObserver observer)
|
public void addGameReadyObserver (GameReadyObserver observer)
|
||||||
{
|
{
|
||||||
@@ -87,8 +82,8 @@ public class ParlorDirector extends BasicDirector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the specified observer from the list of entities that are
|
* Removes the specified observer from the list of entities that are notified when we receive a
|
||||||
* notified when we receive a game ready notification.
|
* game ready notification.
|
||||||
*/
|
*/
|
||||||
public void removeGameReadyObserver (GameReadyObserver observer)
|
public void removeGameReadyObserver (GameReadyObserver observer)
|
||||||
{
|
{
|
||||||
@@ -96,24 +91,19 @@ public class ParlorDirector extends BasicDirector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the named user be invited to a game described by the
|
* Requests that the named user be invited to a game described by the supplied game config.
|
||||||
* supplied game config.
|
|
||||||
*
|
*
|
||||||
* @param invitee the user to invite.
|
* @param invitee the user to invite.
|
||||||
* @param config the configuration of the game to which the user is
|
* @param config the configuration of the game to which the user is being invited.
|
||||||
* being invited.
|
* @param observer the entity that will be notified if this invitation is accepted, refused or
|
||||||
* @param observer the entity that will be notified if this invitation
|
* countered.
|
||||||
* is accepted, refused or countered.
|
|
||||||
*
|
*
|
||||||
* @return an invitation object that can be used to manage the
|
* @return an invitation object that can be used to manage the outstanding invitation.
|
||||||
* outstanding invitation.
|
|
||||||
*/
|
*/
|
||||||
public Invitation invite (Name invitee, GameConfig config,
|
public Invitation invite (Name invitee, GameConfig config, InvitationResponseObserver observer)
|
||||||
InvitationResponseObserver observer)
|
|
||||||
{
|
{
|
||||||
// create the invitation record
|
// create the invitation record
|
||||||
Invitation invite = new Invitation(
|
Invitation invite = new Invitation(_ctx, _pservice, invitee, config, observer);
|
||||||
_ctx, _pservice, invitee, config, observer);
|
|
||||||
// submit the invitation request to the server
|
// submit the invitation request to the server
|
||||||
_pservice.invite(_ctx.getClient(), invitee, config, invite);
|
_pservice.invite(_ctx.getClient(), invitee, config, invite);
|
||||||
// and return the invitation to the caller
|
// and return the invitation to the caller
|
||||||
@@ -123,13 +113,10 @@ public class ParlorDirector extends BasicDirector
|
|||||||
/**
|
/**
|
||||||
* Requests that the specified single player game be started.
|
* Requests that the specified single player game be started.
|
||||||
*
|
*
|
||||||
* @param config the configuration of the single player game to be
|
* @param config the configuration of the single player game to be started.
|
||||||
* started.
|
* @param listener a listener to be informed of failure if the game cannot be started.
|
||||||
* @param listener a listener to be informed of failure if the game
|
|
||||||
* cannot be started.
|
|
||||||
*/
|
*/
|
||||||
public void startSolitaire (
|
public void startSolitaire (GameConfig config, InvocationService.ConfirmListener listener)
|
||||||
GameConfig config, InvocationService.ConfirmListener listener)
|
|
||||||
{
|
{
|
||||||
_pservice.startSolitaire(_ctx.getClient(), config, listener);
|
_pservice.startSolitaire(_ctx.getClient(), config, listener);
|
||||||
}
|
}
|
||||||
@@ -142,13 +129,6 @@ public class ParlorDirector extends BasicDirector
|
|||||||
_pendingInvites.clear();
|
_pendingInvites.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
|
||||||
protected void fetchServices (Client client)
|
|
||||||
{
|
|
||||||
// get a handle on our parlor services
|
|
||||||
_pservice = (ParlorService)client.requireService(ParlorService.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void gameIsReady (int gameOid)
|
public void gameIsReady (int gameOid)
|
||||||
{
|
{
|
||||||
@@ -161,8 +141,8 @@ public class ParlorDirector extends BasicDirector
|
|||||||
handled = grob.receivedGameReady(gameOid) || handled;
|
handled = grob.receivedGameReady(gameOid) || handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if none of the observers took matters into their own hands,
|
// if none of the observers took matters into their own hands, then we'll head on over to
|
||||||
// then we'll head on over to the game room ourselves
|
// the game room ourselves
|
||||||
if (!handled) {
|
if (!handled) {
|
||||||
_ctx.getLocationDirector().moveTo(gameOid);
|
_ctx.getLocationDirector().moveTo(gameOid);
|
||||||
}
|
}
|
||||||
@@ -172,8 +152,7 @@ public class ParlorDirector extends BasicDirector
|
|||||||
public void receivedInvite (int remoteId, Name inviter, GameConfig config)
|
public void receivedInvite (int remoteId, Name inviter, GameConfig config)
|
||||||
{
|
{
|
||||||
// create an invitation record for this invitation
|
// create an invitation record for this invitation
|
||||||
Invitation invite = new Invitation(
|
Invitation invite = new Invitation(_ctx, _pservice, inviter, config, null);
|
||||||
_ctx, _pservice, inviter, config, null);
|
|
||||||
invite.inviteId = remoteId;
|
invite.inviteId = remoteId;
|
||||||
|
|
||||||
// put it in the pending invitations table
|
// put it in the pending invitations table
|
||||||
@@ -184,22 +163,19 @@ public class ParlorDirector extends BasicDirector
|
|||||||
_handler.invitationReceived(invite);
|
_handler.invitationReceived(invite);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Invitation handler choked on invite " +
|
Log.warning("Invitation handler choked on invite notification " + invite + ".");
|
||||||
"notification " + invite + ".");
|
|
||||||
Log.logStackTrace(e);
|
Log.logStackTrace(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void receivedInviteResponse (
|
public void receivedInviteResponse (int remoteId, int code, Object arg)
|
||||||
int remoteId, int code, Object arg)
|
|
||||||
{
|
{
|
||||||
// look up the invitation record for this invitation
|
// look up the invitation record for this invitation
|
||||||
Invitation invite = (Invitation)_pendingInvites.get(remoteId);
|
Invitation invite = (Invitation)_pendingInvites.get(remoteId);
|
||||||
if (invite == null) {
|
if (invite == null) {
|
||||||
Log.warning("Have no record of invitation for which we " +
|
Log.warning("Have no record of invitation for which we received a response?! " +
|
||||||
"received a response?! [remoteId=" + remoteId +
|
"[remoteId=" + remoteId + ", code=" + code + ", arg=" + arg + "].");
|
||||||
", code=" + code + ", arg=" + arg + "].");
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
invite.receivedResponse(code, arg);
|
invite.receivedResponse(code, arg);
|
||||||
@@ -212,9 +188,22 @@ public class ParlorDirector extends BasicDirector
|
|||||||
// TBD
|
// TBD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override // from BasicDirector
|
||||||
|
protected void registerServices (Client client)
|
||||||
|
{
|
||||||
|
client.addServiceGroup(PARLOR_GROUP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override // from BasicDirector
|
||||||
|
protected void fetchServices (Client client)
|
||||||
|
{
|
||||||
|
// get a handle on our parlor services
|
||||||
|
_pservice = (ParlorService)client.requireService(ParlorService.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Register a new invitation in our pending invitations table. The
|
* Register a new invitation in our pending invitations table. The invitation will call this
|
||||||
* invitation will call this when it knows its invitation id.
|
* when it knows its invitation id.
|
||||||
*/
|
*/
|
||||||
protected void registerInvitation (Invitation invite)
|
protected void registerInvitation (Invitation invite)
|
||||||
{
|
{
|
||||||
@@ -222,8 +211,8 @@ public class ParlorDirector extends BasicDirector
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by an invitation when it knows it is no longer and can be
|
* Called by an invitation when it knows it is no longer and can be cleared from the pending
|
||||||
* cleared from the pending invitations table.
|
* invitations table.
|
||||||
*/
|
*/
|
||||||
protected void clearInvitation (Invitation invite)
|
protected void clearInvitation (Invitation invite)
|
||||||
{
|
{
|
||||||
@@ -236,15 +225,13 @@ public class ParlorDirector extends BasicDirector
|
|||||||
/** Provides access to parlor server side services. */
|
/** Provides access to parlor server side services. */
|
||||||
protected ParlorService _pservice;
|
protected ParlorService _pservice;
|
||||||
|
|
||||||
/** The entity that has registered itself to handle incoming
|
/** The entity that has registered itself to handle incoming invitation notifications. */
|
||||||
* invitation notifications. */
|
|
||||||
protected InvitationHandler _handler;
|
protected InvitationHandler _handler;
|
||||||
|
|
||||||
/** A table of acknowledged (but not yet accepted or refused)
|
/** A table of acknowledged (but not yet accepted or refused) invitation requests, keyed on
|
||||||
* invitation requests, keyed on invitation id. */
|
* invitation id. */
|
||||||
protected HashIntMap _pendingInvites = new HashIntMap();
|
protected HashIntMap _pendingInvites = new HashIntMap();
|
||||||
|
|
||||||
/** We notify the entities on this list when we get a game ready
|
/** We notify the entities on this list when we get a game ready notification. */
|
||||||
* notification. */
|
|
||||||
protected ArrayList _grobs = new ArrayList();
|
protected ArrayList _grobs = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ import com.threerings.presents.data.InvocationCodes;
|
|||||||
*/
|
*/
|
||||||
public interface ParlorCodes extends InvocationCodes
|
public interface ParlorCodes extends InvocationCodes
|
||||||
{
|
{
|
||||||
|
/** Defines our invocation services group. */
|
||||||
|
public static final String PARLOR_GROUP = "parlor";
|
||||||
|
|
||||||
/** The response code for an accepted invitation. */
|
/** The response code for an accepted invitation. */
|
||||||
public static final int INVITATION_ACCEPTED = 0;
|
public static final int INVITATION_ACCEPTED = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -36,10 +36,9 @@ import com.threerings.parlor.game.data.GameConfig;
|
|||||||
import com.threerings.parlor.game.server.GameManager;
|
import com.threerings.parlor.game.server.GameManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parlor manager is responsible for the parlor services in
|
* The parlor manager is responsible for the parlor services in aggregate. This includes
|
||||||
* aggregate. This includes maintaining the registry of active games,
|
* maintaining the registry of active games, handling the necessary coordination for the
|
||||||
* handling the necessary coordination for the matchmaking services and
|
* matchmaking services and anything else that falls outside the scope of an actual in-progress
|
||||||
* anything else that falls outside the scope of an actual in-progress
|
|
||||||
* game.
|
* game.
|
||||||
*/
|
*/
|
||||||
public class ParlorManager
|
public class ParlorManager
|
||||||
@@ -49,41 +48,36 @@ public class ParlorManager
|
|||||||
public ParlorProvider parprov;
|
public ParlorProvider parprov;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the parlor manager. This should be called by the server
|
* Initializes the parlor manager. This should be called by the server that is making use of
|
||||||
* that is making use of the parlor services on the single instance of
|
* the parlor services on the single instance of parlor manager that it has created.
|
||||||
* parlor manager that it has created.
|
|
||||||
*
|
*
|
||||||
* @param invmgr a reference to the invocation manager in use by this
|
* @param invmgr a reference to the invocation manager in use by this server.
|
||||||
* server.
|
* @param plreg a reference to the place registry to be used by the parlor manager when
|
||||||
* @param plreg a reference to the place registry to be used by the
|
* creating game places.
|
||||||
* parlor manager when creating game places.
|
|
||||||
*/
|
*/
|
||||||
public void init (InvocationManager invmgr, PlaceRegistry plreg)
|
public void init (InvocationManager invmgr, PlaceRegistry plreg)
|
||||||
{
|
{
|
||||||
// create and register our invocation provider
|
// create and register our invocation provider
|
||||||
parprov = new ParlorProvider(this);
|
parprov = new ParlorProvider(this);
|
||||||
invmgr.registerDispatcher(new ParlorDispatcher(parprov), true);
|
invmgr.registerDispatcher(new ParlorDispatcher(parprov), PARLOR_GROUP);
|
||||||
|
|
||||||
// keep this for later
|
// keep this for later
|
||||||
_plreg = plreg;
|
_plreg = plreg;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Issues an invitation from the <code>inviter</code> to the
|
* Issues an invitation from the <code>inviter</code> to the <code>invitee</code> for a game as
|
||||||
* <code>invitee</code> for a game as described by the supplied config
|
* described by the supplied config object.
|
||||||
* object.
|
|
||||||
*
|
*
|
||||||
* @param inviter the player initiating the invitation.
|
* @param inviter the player initiating the invitation.
|
||||||
* @param invitee the player being invited.
|
* @param invitee the player being invited.
|
||||||
* @param config the configuration of the game being proposed.
|
* @param config the configuration of the game being proposed.
|
||||||
*
|
*
|
||||||
* @return the invitation identifier for the newly created invitation
|
* @return the invitation identifier for the newly created invitation record.
|
||||||
* record.
|
|
||||||
*
|
*
|
||||||
* @exception InvocationException thrown if the invitation was not
|
* @exception InvocationException thrown if the invitation was not able to be processed for
|
||||||
* able to be processed for some reason (like the invited player has
|
* some reason (like the invited player has requested not to be disturbed). The explanation
|
||||||
* requested not to be disturbed). The explanation will be provided in
|
* will be provided in the message data of the exception.
|
||||||
* the message data of the exception.
|
|
||||||
*/
|
*/
|
||||||
public int invite (BodyObject inviter, BodyObject invitee,
|
public int invite (BodyObject inviter, BodyObject invitee,
|
||||||
GameConfig config)
|
GameConfig config)
|
||||||
@@ -92,9 +86,8 @@ public class ParlorManager
|
|||||||
// Log.info("Received invitation request [inviter=" + inviter +
|
// Log.info("Received invitation request [inviter=" + inviter +
|
||||||
// ", invitee=" + invitee + ", config=" + config + "].");
|
// ", invitee=" + invitee + ", config=" + config + "].");
|
||||||
|
|
||||||
// here we should check to make sure the invitee hasn't muted the
|
// here we should check to make sure the invitee hasn't muted the inviter, and that the
|
||||||
// inviter, and that the inviter isn't shunned and all that other
|
// inviter isn't shunned and all that other access control type stuff
|
||||||
// access control type stuff
|
|
||||||
|
|
||||||
// create a new invitation record for this invitation
|
// create a new invitation record for this invitation
|
||||||
Invitation invite = new Invitation(inviter, invitee, config);
|
Invitation invite = new Invitation(inviter, invitee, config);
|
||||||
@@ -103,31 +96,25 @@ public class ParlorManager
|
|||||||
_invites.put(invite.inviteId, invite);
|
_invites.put(invite.inviteId, invite);
|
||||||
|
|
||||||
// deliver an invite notification to the invitee
|
// deliver an invite notification to the invitee
|
||||||
ParlorSender.sendInvite(
|
ParlorSender.sendInvite(invitee, invite.inviteId, inviter.getVisibleName(), config);
|
||||||
invitee, invite.inviteId, inviter.getVisibleName(), config);
|
|
||||||
|
|
||||||
// and let the caller know the invite id we assigned
|
// and let the caller know the invite id we assigned
|
||||||
return invite.inviteId;
|
return invite.inviteId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects a response to an invitation (accept, refuse or counter),
|
* Effects a response to an invitation (accept, refuse or counter), made by the specified
|
||||||
* made by the specified source user with the specified arguments.
|
* source user with the specified arguments.
|
||||||
*
|
*
|
||||||
* @param source the body object of the user that is issuing this
|
* @param source the body object of the user that is issuing this response.
|
||||||
* response.
|
* @param inviteId the identifier of the invitation to which we are responding.
|
||||||
* @param inviteId the identifier of the invitation to which we are
|
* @param code the response code (either {@link #INVITATION_ACCEPTED}, {@link
|
||||||
* responding.
|
* #INVITATION_REFUSED} or {@link #INVITATION_COUNTERED}).
|
||||||
* @param code the response code (either {@link
|
* @param arg the argument that goes along with the response: an explanatory message in the
|
||||||
* #INVITATION_ACCEPTED}, {@link #INVITATION_REFUSED} or {@link
|
* case of a refusal (the empty string, not null, if no message was provided) or the new game
|
||||||
* #INVITATION_COUNTERED}).
|
* configuration in the case of a counter-invitation.
|
||||||
* @param arg the argument that goes along with the response: an
|
|
||||||
* explanatory message in the case of a refusal (the empty string, not
|
|
||||||
* null, if no message was provided) or the new game configuration in
|
|
||||||
* the case of a counter-invitation.
|
|
||||||
*/
|
*/
|
||||||
public void respondToInvite (BodyObject source, int inviteId, int code,
|
public void respondToInvite (BodyObject source, int inviteId, int code, Object arg)
|
||||||
Object arg)
|
|
||||||
{
|
{
|
||||||
// look up the invitation
|
// look up the invitation
|
||||||
Invitation invite = (Invitation)_invites.get(inviteId);
|
Invitation invite = (Invitation)_invites.get(inviteId);
|
||||||
@@ -146,23 +133,21 @@ public class ParlorManager
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// let the other user know that a response was made to this
|
// let the other user know that a response was made to this invitation
|
||||||
// invitation
|
|
||||||
ParlorSender.sendInviteResponse(
|
ParlorSender.sendInviteResponse(
|
||||||
invite.inviter, invite.inviteId, code, arg);
|
invite.inviter, invite.inviteId, code, arg);
|
||||||
|
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case INVITATION_ACCEPTED:
|
case INVITATION_ACCEPTED:
|
||||||
// the invitation was accepted, so we'll need to start up the
|
// the invitation was accepted, so we'll need to start up the game and get the
|
||||||
// game and get the necessary balls rolling
|
// necessary balls rolling
|
||||||
processAcceptedInvitation(invite);
|
processAcceptedInvitation(invite);
|
||||||
// and remove the invitation from the pending table
|
// and remove the invitation from the pending table
|
||||||
_invites.remove(inviteId);
|
_invites.remove(inviteId);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INVITATION_REFUSED:
|
case INVITATION_REFUSED:
|
||||||
// remove the invitation record from the pending table as it
|
// remove the invitation record from the pending table as it is no longer pending
|
||||||
// is no longer pending
|
|
||||||
_invites.remove(inviteId);
|
_invites.remove(inviteId);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -172,9 +157,8 @@ public class ParlorManager
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log.warning("Requested to respond to invitation with " +
|
Log.warning("Requested to respond to invitation with unknown response code " +
|
||||||
"unknown response code [source=" + source +
|
"[source=" + source + ", invite=" + invite + ", code=" + code +
|
||||||
", invite=" + invite + ", code=" + code +
|
|
||||||
", arg=" + arg + "].");
|
", arg=" + arg + "].");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -183,8 +167,7 @@ public class ParlorManager
|
|||||||
/**
|
/**
|
||||||
* Requests that an outstanding invitation be cancelled.
|
* Requests that an outstanding invitation be cancelled.
|
||||||
*
|
*
|
||||||
* @param source the body object of the user that is making the
|
* @param source the body object of the user that is making the request.
|
||||||
* request.
|
|
||||||
* @param inviteId the unique id of the invitation to be cancelled.
|
* @param inviteId the unique id of the invitation to be cancelled.
|
||||||
*/
|
*/
|
||||||
public void cancelInvite (BodyObject source, int inviteId)
|
public void cancelInvite (BodyObject source, int inviteId)
|
||||||
@@ -193,8 +176,7 @@ public class ParlorManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts up and configures the game manager for an accepted
|
* Starts up and configures the game manager for an accepted invitation.
|
||||||
* invitation.
|
|
||||||
*/
|
*/
|
||||||
protected void processAcceptedInvitation (Invitation invite)
|
protected void processAcceptedInvitation (Invitation invite)
|
||||||
{
|
{
|
||||||
@@ -202,25 +184,21 @@ public class ParlorManager
|
|||||||
Log.info("Creating game manager [invite=" + invite + "].");
|
Log.info("Creating game manager [invite=" + invite + "].");
|
||||||
|
|
||||||
// configure the game config with the player info
|
// configure the game config with the player info
|
||||||
invite.config.players = new Name[] {
|
invite.config.players = new Name[] { invite.invitee.getVisibleName(),
|
||||||
invite.invitee.getVisibleName(),
|
invite.inviter.getVisibleName() };
|
||||||
invite.inviter.getVisibleName() };
|
|
||||||
|
|
||||||
// create the game manager and begin it's initialization process;
|
// create the game manager and begin it's initialization process; the game manager will
|
||||||
// the game manager will take care of notifying the players that
|
// take care of notifying the players that the game has been created
|
||||||
// the game has been created
|
|
||||||
_plreg.createPlace(invite.config);
|
_plreg.createPlace(invite.config);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.warning("Unable to create game manager [invite=" + invite +
|
Log.warning("Unable to create game manager [invite=" + invite + ", error=" + e + "].");
|
||||||
", error=" + e + "].");
|
|
||||||
Log.logStackTrace(e);
|
Log.logStackTrace(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The invitation record is used by the parlor manager to keep track
|
* The invitation record is used by the parlor manager to keep track of pending invitations.
|
||||||
* of pending invitations.
|
|
||||||
*/
|
*/
|
||||||
protected static class Invitation
|
protected static class Invitation
|
||||||
{
|
{
|
||||||
@@ -237,11 +215,9 @@ public class ParlorManager
|
|||||||
public GameConfig config;
|
public GameConfig config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new invitation with the specified participants and
|
* Constructs a new invitation with the specified participants and configuration.
|
||||||
* configuration.
|
|
||||||
*/
|
*/
|
||||||
public Invitation (BodyObject inviter, BodyObject invitee,
|
public Invitation (BodyObject inviter, BodyObject invitee, GameConfig config)
|
||||||
GameConfig config)
|
|
||||||
{
|
{
|
||||||
this.inviter = inviter;
|
this.inviter = inviter;
|
||||||
this.invitee = invitee;
|
this.invitee = invitee;
|
||||||
@@ -249,8 +225,8 @@ public class ParlorManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swaps the inviter and invitee which is necessary when the
|
* Swaps the inviter and invitee which is necessary when the invitee responds with a
|
||||||
* invitee responds with a counter-invitation.
|
* counter-invitation.
|
||||||
*/
|
*/
|
||||||
public void swapControl ()
|
public void swapControl ()
|
||||||
{
|
{
|
||||||
@@ -266,7 +242,6 @@ public class ParlorManager
|
|||||||
/** The table of pending invitations. */
|
/** The table of pending invitations. */
|
||||||
protected HashIntMap _invites = new HashIntMap();
|
protected HashIntMap _invites = new HashIntMap();
|
||||||
|
|
||||||
/** A counter used to generate unique identifiers for invitation
|
/** A counter used to generate unique identifiers for invitation records. */
|
||||||
* records. */
|
|
||||||
protected static int _nextInviteId = 0;
|
protected static int _nextInviteId = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ public abstract class PuzzleManager extends GameManager
|
|||||||
|
|
||||||
// create and fill in our game service object
|
// create and fill in our game service object
|
||||||
PuzzleGameMarshaller service = (PuzzleGameMarshaller)
|
PuzzleGameMarshaller service = (PuzzleGameMarshaller)
|
||||||
_invmgr.registerDispatcher(new PuzzleGameDispatcher(this), false);
|
_invmgr.registerDispatcher(new PuzzleGameDispatcher(this));
|
||||||
_puzobj.setPuzzleGameService(service);
|
_puzobj.setPuzzleGameService(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -248,8 +248,7 @@ public class StageSceneManager extends SpotSceneManager
|
|||||||
|
|
||||||
// register and fill in our stage scene service
|
// register and fill in our stage scene service
|
||||||
StageSceneMarshaller service = (StageSceneMarshaller)
|
StageSceneMarshaller service = (StageSceneMarshaller)
|
||||||
StageServer.invmgr.registerDispatcher(
|
StageServer.invmgr.registerDispatcher(new StageSceneDispatcher(this));
|
||||||
new StageSceneDispatcher(this), false);
|
|
||||||
_ssobj.setStageSceneService(service);
|
_ssobj.setStageSceneService(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -495,6 +495,12 @@ public class SceneDirector extends BasicDirector
|
|||||||
_sservice = null;
|
_sservice = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// documentation inherited from interface
|
||||||
|
protected void registerServices (Client client)
|
||||||
|
{
|
||||||
|
client.addServiceGroup(WHIRLED_GROUP);
|
||||||
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
protected void fetchServices (Client client)
|
protected void fetchServices (Client client)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ import com.threerings.crowd.data.LocationCodes;
|
|||||||
*/
|
*/
|
||||||
public interface SceneCodes extends LocationCodes
|
public interface SceneCodes extends LocationCodes
|
||||||
{
|
{
|
||||||
|
/** Defines our invocation services group. */
|
||||||
|
public static final String WHIRLED_GROUP = "whirled";
|
||||||
|
|
||||||
/** The message identifier for scene update messages. */
|
/** The message identifier for scene update messages. */
|
||||||
public static final String SCENE_UPDATE = "scene_update";
|
public static final String SCENE_UPDATE = "scene_update";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,26 +35,23 @@ import com.threerings.crowd.server.PlaceRegistry;
|
|||||||
|
|
||||||
import com.threerings.whirled.Log;
|
import com.threerings.whirled.Log;
|
||||||
import com.threerings.whirled.data.Scene;
|
import com.threerings.whirled.data.Scene;
|
||||||
|
import com.threerings.whirled.data.SceneCodes;
|
||||||
import com.threerings.whirled.data.SceneModel;
|
import com.threerings.whirled.data.SceneModel;
|
||||||
import com.threerings.whirled.server.persist.SceneRepository;
|
import com.threerings.whirled.server.persist.SceneRepository;
|
||||||
import com.threerings.whirled.util.SceneFactory;
|
import com.threerings.whirled.util.SceneFactory;
|
||||||
import com.threerings.whirled.util.UpdateList;
|
import com.threerings.whirled.util.UpdateList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The scene registry is responsible for the management of all scenes. It
|
* The scene registry is responsible for the management of all scenes. It handles interaction with
|
||||||
* handles interaction with the scene repository and ensures that scenes
|
* the scene repository and ensures that scenes are loaded into memory when needed and flushed from
|
||||||
* are loaded into memory when needed and flushed from memory when not
|
* memory when not needed.
|
||||||
* needed.
|
|
||||||
*
|
*
|
||||||
* <p> The scene repository also takes care of bridging from the blocking,
|
* <p> The scene repository also takes care of bridging from the blocking, synchronous world of the
|
||||||
* synchronous world of the scene repository to the non-blocking
|
* scene repository to the non-blocking asynchronous world of the distributed object event
|
||||||
* asynchronous world of the distributed object event queue. Thus its
|
* queue. Thus its interfaces for accessing scenes are structured so as to not block the dobjmgr
|
||||||
* interfaces for accessing scenes are structured so as to not block the
|
* thread while waiting for scenes to be read from or written to the repository.
|
||||||
* dobjmgr thread while waiting for scenes to be read from or written to
|
|
||||||
* the repository.
|
|
||||||
*
|
*
|
||||||
* <p><em>Note:</em> All access to the scene registry should take place
|
* <p><em>Note:</em> All access to the scene registry should take place from the dobjmgr thread.
|
||||||
* from the dobjmgr thread.
|
|
||||||
*/
|
*/
|
||||||
public class SceneRegistry
|
public class SceneRegistry
|
||||||
{
|
{
|
||||||
@@ -64,8 +61,7 @@ public class SceneRegistry
|
|||||||
public static interface ConfigFactory
|
public static interface ConfigFactory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates the place config instance appropriate to the specified
|
* Creates the place config instance appropriate to the specified scene.
|
||||||
* scene.
|
|
||||||
*/
|
*/
|
||||||
PlaceConfig createPlaceConfig (SceneModel model);
|
PlaceConfig createPlaceConfig (SceneModel model);
|
||||||
}
|
}
|
||||||
@@ -74,8 +70,8 @@ public class SceneRegistry
|
|||||||
public SceneProvider sceneprov;
|
public SceneProvider sceneprov;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a scene registry, instructing it to load and store
|
* Constructs a scene registry, instructing it to load and store scenes using the supplied
|
||||||
* scenes using the supplied scene repository.
|
* scene repository.
|
||||||
*/
|
*/
|
||||||
public SceneRegistry (InvocationManager invmgr, SceneRepository screp,
|
public SceneRegistry (InvocationManager invmgr, SceneRepository screp,
|
||||||
SceneFactory scfact, ConfigFactory confact)
|
SceneFactory scfact, ConfigFactory confact)
|
||||||
@@ -86,14 +82,14 @@ public class SceneRegistry
|
|||||||
|
|
||||||
// create/register a scene provider with the invocation services
|
// create/register a scene provider with the invocation services
|
||||||
sceneprov = new SceneProvider(CrowdServer.plreg.locprov, this);
|
sceneprov = new SceneProvider(CrowdServer.plreg.locprov, this);
|
||||||
invmgr.registerDispatcher(new SceneDispatcher(sceneprov), true);
|
invmgr.registerDispatcher(new SceneDispatcher(sceneprov), SceneCodes.WHIRLED_GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches the scene manager assosciated with the specified scene.
|
* Fetches the scene manager assosciated with the specified scene.
|
||||||
*
|
*
|
||||||
* @return the scene manager for the specified scene or null if no
|
* @return the scene manager for the specified scene or null if no scene manager is loaded for
|
||||||
* scene manager is loaded for that scene.
|
* that scene.
|
||||||
*/
|
*/
|
||||||
public SceneManager getSceneManager (int sceneId)
|
public SceneManager getSceneManager (int sceneId)
|
||||||
{
|
{
|
||||||
@@ -101,8 +97,7 @@ public class SceneRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the scene repository in use by this
|
* Returns a reference to the scene repository in use by this registry.
|
||||||
* registry.
|
|
||||||
*/
|
*/
|
||||||
public SceneRepository getSceneRepository ()
|
public SceneRepository getSceneRepository ()
|
||||||
{
|
{
|
||||||
@@ -110,9 +105,8 @@ public class SceneRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@link SceneManager#where} for the specified scene or
|
* Returns {@link SceneManager#where} for the specified scene or <code>null:sceneId</code> if
|
||||||
* <code>null:sceneId</code> if no scene manager exists for that
|
* no scene manager exists for that scene.
|
||||||
* scene.
|
|
||||||
*/
|
*/
|
||||||
public String where (int sceneId)
|
public String where (int sceneId)
|
||||||
{
|
{
|
||||||
@@ -121,39 +115,35 @@ public class SceneRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Because scenes must be loaded from the scene repository and this
|
* Because scenes must be loaded from the scene repository and this must not be done on the
|
||||||
* must not be done on the dobjmgr thread, the interface for resolving
|
* dobjmgr thread, the interface for resolving scenes requires that the entity that wishes for
|
||||||
* scenes requires that the entity that wishes for a scene to be
|
* a scene to be resolved implement this callback interface so that it can be notified when a
|
||||||
* resolved implement this callback interface so that it can be
|
* scene has been loaded and initialized.
|
||||||
* notified when a scene has been loaded and initialized.
|
|
||||||
*/
|
*/
|
||||||
public static interface ResolutionListener
|
public static interface ResolutionListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Called when the scene has been successfully resolved. The scene
|
* Called when the scene has been successfully resolved. The scene manager instance
|
||||||
* manager instance provided can be used to obtain a reference to
|
* provided can be used to obtain a reference to the scene, or the scene distributed
|
||||||
* the scene, or the scene distributed object.
|
* object.
|
||||||
*/
|
*/
|
||||||
public void sceneWasResolved (SceneManager scmgr);
|
public void sceneWasResolved (SceneManager scmgr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called if some failure occurred in the scene resolution
|
* Called if some failure occurred in the scene resolution process.
|
||||||
* process.
|
|
||||||
*/
|
*/
|
||||||
public void sceneFailedToResolve (int sceneId, Exception reason);
|
public void sceneFailedToResolve (int sceneId, Exception reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that the specified scene be resolved, which means loaded into
|
* Requests that the specified scene be resolved, which means loaded into the server and
|
||||||
* the server and initialized if the scene is not currently active. The
|
* initialized if the scene is not currently active. The supplied callback instance will be
|
||||||
* supplied callback instance will be notified, on the dobjmgr thread, when
|
* notified, on the dobjmgr thread, when the scene has been resolved. If the scene is already
|
||||||
* the scene has been resolved. If the scene is already active, it will be
|
* active, it will be notified immediately (before the call to {@link #resolveScene} returns).
|
||||||
* notified immediately (before the call to {@link #resolveScene} returns).
|
|
||||||
*
|
*
|
||||||
* @param sceneId the id of the scene to resolve.
|
* @param sceneId the id of the scene to resolve.
|
||||||
* @param target a reference to a callback instance that will be notified
|
* @param target a reference to a callback instance that will be notified when the scene has
|
||||||
* when the scene has been resolved (which may be immediately if the scene
|
* been resolved (which may be immediately if the scene is already active).
|
||||||
* is already active).
|
|
||||||
*/
|
*/
|
||||||
public void resolveScene (int sceneId, ResolutionListener target)
|
public void resolveScene (int sceneId, ResolutionListener target)
|
||||||
{
|
{
|
||||||
@@ -168,37 +158,31 @@ public class SceneRegistry
|
|||||||
Log.debug("Resolving scene [id=" + sceneId + "].");
|
Log.debug("Resolving scene [id=" + sceneId + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise we've got to resolve the scene and call them back
|
// otherwise we've got to resolve the scene and call them back later; we can manipulate the
|
||||||
// later; we can manipulate the penders table with impunity here
|
// penders table with impunity here because we only do so on the dobjmgr thread
|
||||||
// because we only do so on the dobjmgr thread
|
|
||||||
ArrayList penders = (ArrayList)_penders.get(sceneId);
|
ArrayList penders = (ArrayList)_penders.get(sceneId);
|
||||||
|
|
||||||
// if we're already in the process of resolving this scene, just
|
// if we're already in the process of resolving this scene, just add these guys to the list
|
||||||
// add these guys to the list to be notified when it finally is
|
// to be notified when it finally is resolved
|
||||||
// resolved
|
|
||||||
if (penders != null) {
|
if (penders != null) {
|
||||||
penders.add(target);
|
penders.add(target);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// otherwise we've got to initiate the resolution process.
|
// otherwise we've got to initiate the resolution process, create the penders list
|
||||||
// first we create the penders list
|
|
||||||
_penders.put(sceneId, penders = new ArrayList());
|
_penders.put(sceneId, penders = new ArrayList());
|
||||||
penders.add(target);
|
penders.add(target);
|
||||||
|
|
||||||
// i don't like cluttering up method declarations with final
|
// i don't like cluttering up method declarations with final keywords...
|
||||||
// keywords...
|
|
||||||
final int fsceneId = sceneId;
|
final int fsceneId = sceneId;
|
||||||
|
|
||||||
if (Log.debug()) {
|
if (Log.debug()) {
|
||||||
Log.debug("Invoking scene lookup [id=" + sceneId + "].");
|
Log.debug("Invoking scene lookup [id=" + sceneId + "].");
|
||||||
}
|
}
|
||||||
|
|
||||||
// then we queue up an execution unit that'll load the scene
|
// then we queue up an execution unit that'll load the scene and initialize it etc.
|
||||||
// and initialize it and all that
|
|
||||||
WhirledServer.invoker.postUnit(new Invoker.Unit() {
|
WhirledServer.invoker.postUnit(new Invoker.Unit() {
|
||||||
// this is run on the invoker thread
|
// this is run on the invoker thread
|
||||||
public boolean invoke ()
|
public boolean invoke () {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
_model = _screp.loadSceneModel(fsceneId);
|
_model = _screp.loadSceneModel(fsceneId);
|
||||||
_updates = _screp.loadUpdates(fsceneId);
|
_updates = _screp.loadUpdates(fsceneId);
|
||||||
@@ -209,23 +193,19 @@ public class SceneRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this is run on the dobjmgr thread
|
// this is run on the dobjmgr thread
|
||||||
public void handleResult ()
|
public void handleResult () {
|
||||||
{
|
|
||||||
if (_cause != null) {
|
if (_cause != null) {
|
||||||
processFailedResolution(fsceneId, _cause);
|
processFailedResolution(fsceneId, _cause);
|
||||||
} else if (_model != null) {
|
} else if (_model != null) {
|
||||||
processSuccessfulResolution(_model, _updates);
|
processSuccessfulResolution(_model, _updates);
|
||||||
} else {
|
} else {
|
||||||
Log.warning("Scene loading unit finished with " +
|
Log.warning("Scene loading unit finished with neither a scene nor a " +
|
||||||
"neither a scene nor a reason for " +
|
"reason for failure!?");
|
||||||
"failure!?");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString ()
|
public String toString () {
|
||||||
{
|
return "SceneRegistry.SceneLoader " + (_model == null ? "" : _model.name) +
|
||||||
return "SceneRegistry.SceneLoader " +
|
|
||||||
(_model == null ? "" : _model.name) +
|
|
||||||
"(" + fsceneId + ")";
|
"(" + fsceneId + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,28 +222,24 @@ public class SceneRegistry
|
|||||||
protected void processSuccessfulResolution (
|
protected void processSuccessfulResolution (
|
||||||
SceneModel model, final UpdateList updates)
|
SceneModel model, final UpdateList updates)
|
||||||
{
|
{
|
||||||
// now that the scene is loaded, we can create a scene manager for
|
// now that the scene is loaded, we can create a scene manager for it. that will be
|
||||||
// it. that will be initialized by the place registry and when
|
// initialized by the place registry and when that is finally complete, then we can let our
|
||||||
// that is finally complete, then we can let our penders know
|
// penders know what's up
|
||||||
// what's up
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// first create our scene instance
|
// first create our scene instance
|
||||||
final Scene scene = _scfact.createScene(
|
final Scene scene = _scfact.createScene(model, _confact.createPlaceConfig(model));
|
||||||
model, _confact.createPlaceConfig(model));
|
|
||||||
|
|
||||||
// now create our scene manager
|
// now create our scene manager
|
||||||
CrowdServer.plreg.createPlace(scene.getPlaceConfig(),
|
CrowdServer.plreg.createPlace(
|
||||||
new PlaceRegistry.PreStartupHook() {
|
scene.getPlaceConfig(), new PlaceRegistry.PreStartupHook() {
|
||||||
public void invoke (PlaceManager pmgr) {
|
public void invoke (PlaceManager pmgr) {
|
||||||
((SceneManager)pmgr).setSceneData(
|
((SceneManager)pmgr).setSceneData(scene, updates, SceneRegistry.this);
|
||||||
scene, updates, SceneRegistry.this);
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// when the scene manager completes its startup procedings, it will
|
// when the scene manager completes its startup procedings, it will call back to the
|
||||||
// call back to the scene registry and let us know that we can turn
|
// scene registry and let us know that we can turn the penders loose
|
||||||
// the penders loose
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// so close, but no cigar
|
// so close, but no cigar
|
||||||
@@ -276,8 +252,7 @@ public class SceneRegistry
|
|||||||
*/
|
*/
|
||||||
protected void processFailedResolution (int sceneId, Exception cause)
|
protected void processFailedResolution (int sceneId, Exception cause)
|
||||||
{
|
{
|
||||||
Log.info("Failed to resolve scene [sceneId=" + sceneId +
|
Log.info("Failed to resolve scene [sceneId=" + sceneId + ", cause=" + cause + "].");
|
||||||
", cause=" + cause + "].");
|
|
||||||
Log.logStackTrace(cause);
|
Log.logStackTrace(cause);
|
||||||
|
|
||||||
// alas things didn't work out, notify our penders
|
// alas things didn't work out, notify our penders
|
||||||
@@ -296,8 +271,8 @@ public class SceneRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the scene manager once it has started up (meaning that it
|
* Called by the scene manager once it has started up (meaning that it has its place object and
|
||||||
* has its place object and is ready to roll).
|
* is ready to roll).
|
||||||
*/
|
*/
|
||||||
protected void sceneManagerDidStart (SceneManager scmgr)
|
protected void sceneManagerDidStart (SceneManager scmgr)
|
||||||
{
|
{
|
||||||
@@ -306,8 +281,7 @@ public class SceneRegistry
|
|||||||
_scenemgrs.put(sceneId, scmgr);
|
_scenemgrs.put(sceneId, scmgr);
|
||||||
|
|
||||||
if (Log.debug()) {
|
if (Log.debug()) {
|
||||||
Log.debug("Registering scene manager [scid=" + sceneId +
|
Log.debug("Registering scene manager [scid=" + sceneId + ", scmgr=" + scmgr + "].");
|
||||||
", scmgr=" + scmgr + "].");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now notify any penders
|
// now notify any penders
|
||||||
@@ -331,8 +305,7 @@ public class SceneRegistry
|
|||||||
protected void unmapSceneManager (SceneManager scmgr)
|
protected void unmapSceneManager (SceneManager scmgr)
|
||||||
{
|
{
|
||||||
if (_scenemgrs.remove(scmgr.getScene().getId()) == null) {
|
if (_scenemgrs.remove(scmgr.getScene().getId()) == null) {
|
||||||
Log.warning("Requested to unmap unmapped scene manager " +
|
Log.warning("Requested to unmap unmapped scene manager [scmgr=" + scmgr + "].");
|
||||||
"[scmgr=" + scmgr + "].");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -347,8 +320,7 @@ public class SceneRegistry
|
|||||||
/** Used to generate place configs for our scenes. */
|
/** Used to generate place configs for our scenes. */
|
||||||
protected ConfigFactory _confact;
|
protected ConfigFactory _confact;
|
||||||
|
|
||||||
/** The entity via which we create scene instances from scene
|
/** The entity via which we create scene instances from scene models. */
|
||||||
* models. */
|
|
||||||
protected SceneFactory _scfact;
|
protected SceneFactory _scfact;
|
||||||
|
|
||||||
/** A mapping from scene ids to scene managers. */
|
/** A mapping from scene ids to scene managers. */
|
||||||
|
|||||||
@@ -29,11 +29,12 @@ import com.threerings.crowd.server.PlaceRegistry;
|
|||||||
import com.threerings.whirled.server.SceneRegistry;
|
import com.threerings.whirled.server.SceneRegistry;
|
||||||
|
|
||||||
import com.threerings.whirled.zone.Log;
|
import com.threerings.whirled.zone.Log;
|
||||||
|
import com.threerings.whirled.zone.data.ZoneCodes;
|
||||||
import com.threerings.whirled.zone.util.ZoneUtil;
|
import com.threerings.whirled.zone.util.ZoneUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The zone registry takes care of mapping zone requests to the
|
* The zone registry takes care of mapping zone requests to the appropriate registered zone
|
||||||
* appropriate registered zone manager.
|
* manager.
|
||||||
*/
|
*/
|
||||||
public class ZoneRegistry
|
public class ZoneRegistry
|
||||||
{
|
{
|
||||||
@@ -43,29 +44,25 @@ public class ZoneRegistry
|
|||||||
/**
|
/**
|
||||||
* Creates a zone manager with the supplied configuration.
|
* Creates a zone manager with the supplied configuration.
|
||||||
*/
|
*/
|
||||||
public ZoneRegistry (InvocationManager invmgr, PlaceRegistry plreg,
|
public ZoneRegistry (InvocationManager invmgr, PlaceRegistry plreg, SceneRegistry screg)
|
||||||
SceneRegistry screg)
|
|
||||||
{
|
{
|
||||||
// create a zone provider and register it with the invocation
|
// create a zone provider and register it with the invocation services
|
||||||
// services
|
|
||||||
zoneprov = new ZoneProvider(plreg.locprov, this, screg);
|
zoneprov = new ZoneProvider(plreg.locprov, this, screg);
|
||||||
invmgr.registerDispatcher(new ZoneDispatcher(zoneprov), true);
|
invmgr.registerDispatcher(new ZoneDispatcher(zoneprov), ZoneCodes.WHIRLED_GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers the supplied zone manager as the manager for the
|
* Registers the supplied zone manager as the manager for the specified zone type. Zone types
|
||||||
* specified zone type. Zone types are 7 bits and managers are
|
* are 7 bits and managers are responsible for making sure they don't use a zone type that
|
||||||
* responsible for making sure they don't use a zone type that
|
* collides with another manager (given that we have only three zone types at present, this
|
||||||
* collides with another manager (given that we have only three zone
|
* doesn't seem unreasonable).
|
||||||
* types at present, this doesn't seem unreasonable).
|
|
||||||
*/
|
*/
|
||||||
public void registerZoneManager (byte zoneType, ZoneManager manager)
|
public void registerZoneManager (byte zoneType, ZoneManager manager)
|
||||||
{
|
{
|
||||||
ZoneManager old = (ZoneManager)_managers.get(zoneType);
|
ZoneManager old = (ZoneManager)_managers.get(zoneType);
|
||||||
if (old != null) {
|
if (old != null) {
|
||||||
Log.warning("Zone manager already registered with requested " +
|
Log.warning("Zone manager already registered with requested type [type=" + zoneType +
|
||||||
"type [type=" + zoneType + ", old=" + old +
|
", old=" + old + ", new=" + manager + "].");
|
||||||
", new=" + manager + "].");
|
|
||||||
} else {
|
} else {
|
||||||
_managers.put(zoneType, manager);
|
_managers.put(zoneType, manager);
|
||||||
}
|
}
|
||||||
@@ -74,8 +71,7 @@ public class ZoneRegistry
|
|||||||
/**
|
/**
|
||||||
* Returns the zone manager that handles the specified zone id.
|
* Returns the zone manager that handles the specified zone id.
|
||||||
*
|
*
|
||||||
* @param qualifiedZoneId the qualified zone id for which the manager
|
* @param qualifiedZoneId the qualified zone id for which the manager should be looked up.
|
||||||
* should be looked up.
|
|
||||||
*/
|
*/
|
||||||
public ZoneManager getZoneManager (int qualifiedZoneId)
|
public ZoneManager getZoneManager (int qualifiedZoneId)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user