More basic stuff.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@392 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -9,3 +9,13 @@ services and built on top of the Cocktail networking platform.
|
||||
|
||||
The Mi Casa service is comprised of a server that can be configured to
|
||||
have any number of lobbies in which users can get together to play games.
|
||||
|
||||
* Notes
|
||||
Maybe move lobby stuff into parlor.
|
||||
|
||||
Move lobby configuration (which lobbies to load) into database. Make it so
|
||||
that lobbies can be created/destroyed on the fly.
|
||||
|
||||
Sort out a different way for lobbies to get configuration information than
|
||||
being passed a properties file that was extracted from the server
|
||||
configuration. We'll want inheritance and all that.
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// $Id: LobbyCodes.java,v 1.1 2001/10/04 00:29:07 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobdy;
|
||||
|
||||
import com.threerings.cocktail.cher.client.InvocationCodes;
|
||||
|
||||
/**
|
||||
* Contains codes used by the lobby invocation services.
|
||||
*/
|
||||
public interface LobbyCodes extends InvocationCodes
|
||||
{
|
||||
/** The module name for the lobby services. */
|
||||
public static final String MODULE_NAME = "lobby";
|
||||
|
||||
/** The message identifier for a get lobbies request. */
|
||||
public static final String GET_LOBBIES_REQUEST = "GetLobbies";
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// $Id: LobbyManager.java,v 1.1 2001/10/04 00:29:07 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobdy;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import com.threerings.cocktail.party.server.PlaceManager;
|
||||
import com.threerings.micasa.Log;
|
||||
|
||||
/**
|
||||
* Takes care of the server side of a particular lobby.
|
||||
*/
|
||||
public class LobbyManager extends PlaceManager
|
||||
{
|
||||
/**
|
||||
* Initializes this lobby manager with its configuration properties.
|
||||
*
|
||||
* @exception Exception thrown if a configuration error is detected.
|
||||
*/
|
||||
public void init (Properties config)
|
||||
throws Exception
|
||||
{
|
||||
Log.info("Lobby manager initialized.");
|
||||
}
|
||||
|
||||
protected Class getPlaceObjectClass ()
|
||||
{
|
||||
return LobbyObject.class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//
|
||||
// $Id: LobbyObject.dobj,v 1.1 2001/10/04 00:29:07 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobdy;
|
||||
|
||||
import com.threerings.cocktail.party.data.PlaceObject;
|
||||
|
||||
public class LobbyObject extends PlaceObject
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// $Id: LobbyProvider.java,v 1.1 2001/10/04 00:29:07 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobdy;
|
||||
|
||||
import com.threerings.cocktail.cher.server.InvocationProvider;
|
||||
import com.threerings.cocktail.party.data.BodyObject;
|
||||
|
||||
/**
|
||||
* Handles server side of lobby-related invocation services.
|
||||
*/
|
||||
public class LobbyProvider
|
||||
extends InvocationProvider implements LobbyCodes
|
||||
{
|
||||
/**
|
||||
* Constructs a lobby provider instance which will be used to handle
|
||||
* all lobby-related invocation service requests. This is
|
||||
* automatically taken care of by the lobby registry, so no other
|
||||
* entity need instantiate and register a lobby provider.
|
||||
*
|
||||
* @param lobreq a reference to the lobby registry active in this
|
||||
* server.
|
||||
*/
|
||||
public LobbyProvider (LobbyRegistry lobreg)
|
||||
{
|
||||
_lobreg = lobreg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a request by the client to obtain a list of lobbies
|
||||
* matching the supplied pattern string.
|
||||
*/
|
||||
public void handleGetLobbiesRequest (
|
||||
BodyObject source, int invid, String pattern)
|
||||
{
|
||||
}
|
||||
|
||||
/** A reference to the lobby registry. */
|
||||
protected LobbyRegistry _lobreg;
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
//
|
||||
// $Id: LobbyRegistry.java,v 1.1 2001/10/04 00:29:07 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobdy;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import com.samskivert.util.Config;
|
||||
import com.samskivert.util.PropertiesUtil;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
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.
|
||||
*
|
||||
* <p> Presently, the lobby registry is configured with lobbies via the
|
||||
* server configuration. An example configuration follows:
|
||||
*
|
||||
* <pre>
|
||||
* lobby_ids = foolobby, barlobby, bazlobby
|
||||
*
|
||||
* foolobby.mgrclass = com.threerings.micasa.lobby.LobbyManager
|
||||
* foolobby.config1 = some config value
|
||||
* foolobby.config2 = some other config value
|
||||
*
|
||||
* barlobby.mgrclass = com.threerings.micasa.lobby.LobbyManager
|
||||
* ...
|
||||
* </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.
|
||||
*/
|
||||
public class LobbyRegistry
|
||||
{
|
||||
/**
|
||||
* A simple class for keeping track of information for each lobby in
|
||||
* operation on the server.
|
||||
*/
|
||||
public static class Lobby
|
||||
{
|
||||
/** The object id of the lobby place object. */
|
||||
public int placeOid;
|
||||
|
||||
/** The human readable name of the lobby. */
|
||||
public String name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the registry. It will use the supplied configuration
|
||||
* instance to determine which lobbies to load, etc.
|
||||
*/
|
||||
public void init (Config config)
|
||||
{
|
||||
_config = config;
|
||||
|
||||
// create our lobby managers
|
||||
String[] lmgrs = config.getValue(LOBIDS_KEY, (String[])null);
|
||||
if (lmgrs == null || lmgrs.length == 0) {
|
||||
Log.warning("No lobbies specified in config file (via '" +
|
||||
LOBIDS_KEY + "' parameter.");
|
||||
|
||||
} else {
|
||||
for (int i = 0; i < lmgrs.length; i++) {
|
||||
loadLobby(lmgrs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the properties for a lobby from the server config and
|
||||
* creates and initializes the lobby manager.
|
||||
*/
|
||||
protected void loadLobby (String lobbyId)
|
||||
{
|
||||
try {
|
||||
// extract the properties for this lobby
|
||||
Properties props =
|
||||
_config.getProperties(MiCasaServer.CONFIG_KEY);
|
||||
props = PropertiesUtil.getSubProperties(props, lobbyId);
|
||||
|
||||
// get the lobby manager class
|
||||
String lmgrClass = props.getProperty("mgrclass");
|
||||
if (lmgrClass == null) {
|
||||
throw new Exception("Missing 'mgrclass' definition in " +
|
||||
"lobby configuration.");
|
||||
}
|
||||
|
||||
// instantiate the manager class and create the lobby
|
||||
LobbyManager lobmgr = (LobbyManager)
|
||||
MiCasaServer.plreg.createPlace(Class.forName(lmgrClass));
|
||||
|
||||
// initialize the manager
|
||||
lobmgr.init(props);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.warning("Unable to create lobby manager " +
|
||||
"[lobbyId=" + lobbyId + ", error=" + e + "].");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about all lobbies matching the supplied pattern
|
||||
* string. Presently the pattern is interpreted as a simple prefix and
|
||||
* all lobbies matching that prefix will be returned.
|
||||
*
|
||||
* @param pattern the pattern to match or null if all lobbies should
|
||||
* be returned.
|
||||
*/
|
||||
public Lobby[] getLobbies (String pattern)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Config _config;
|
||||
|
||||
/** The configuration key for the lobby managers list. */
|
||||
protected static final String LOBIDS_KEY =
|
||||
MiCasaServer.CONFIG_KEY + ".lobby_ids";
|
||||
}
|
||||
Reference in New Issue
Block a user