com.threerings.micasa.lobby
Class LobbyRegistry

java.lang.Object
  extended by com.threerings.micasa.lobby.LobbyRegistry
All Implemented Interfaces:
LobbyProvider, InvocationProvider

public class LobbyRegistry
extends Object
implements LobbyProvider

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.

Presently, the lobby registry is configured with lobbies via the server configuration. An example configuration follows:

 lobby_ids = foolobby, barlobby, bazlobby

 foolobby.mgrclass = com.threerings.micasa.lobby.LobbyManager
 foolobby.ugi = 
 foolobby.name = 
 foolobby.config1 = some config value
 foolobby.config2 = some other config value

 barlobby.mgrclass = com.threerings.micasa.lobby.LobbyManager
 barlobby.ugi = 
 barlobby.name = 
 ...
 
This information will be loaded from the MiCasa server configuration which means that it should live in rsrc/config/micasa/server.properties somwhere in the classpath where it will override the default MiCasa server properties file.

The UGI 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:

 backgammon,board,strategy
 spades,card,partner
 yahtzee,dice
 
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 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.


Field Summary
protected  int _defLobbyOid
          The oid of the default lobby.
protected  Map<String,List<Lobby>> _lobbies
          A table containing references to our lobby records (in the form of category lists.
protected  PlaceRegistry _plreg
           
protected static String LOBIDS_KEY
          The configuration key for the lobby managers list.
 
Constructor Summary
LobbyRegistry(InvocationManager invmgr)
           
 
Method Summary
 String[] getCategories(BodyObject requester)
          Returns an array containing the category identifiers of all the categories in which lobbies have been registered with the registry.
 void getCategories(ClientObject caller, LobbyService.CategoriesListener listener)
          Processes a request by the client to obtain a list of the lobby categories available on this server.
 int getDefaultLobbyOid()
          Returns the oid of the default lobby.
 void getLobbies(BodyObject requester, String category, List<Lobby> target)
          Returns information about all lobbies hosting games in the specified category.
 void getLobbies(ClientObject caller, String category, LobbyService.LobbiesListener listener)
          Processes a request by the client to obtain a list of lobbies matching the supplied category string.
 void init()
          Initializes the registry, creating our default lobbies.
protected  void loadLobby(String lobbyId)
          Extracts the properties for a lobby from the server config and creates and initializes the lobby manager.
protected  void lobbyReady(int placeOid, String gameIdent, String name)
          Called by our lobby managers once they have started up and are ready to do their lobby duties.
protected  void registerLobby(String category, Lobby record)
          Registers the supplied lobby in the specified category table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_plreg

@Inject
protected PlaceRegistry _plreg

_lobbies

protected Map<String,List<Lobby>> _lobbies
A table containing references to our lobby records (in the form of category lists.


_defLobbyOid

protected int _defLobbyOid
The oid of the default lobby.


LOBIDS_KEY

protected static final String LOBIDS_KEY
The configuration key for the lobby managers list.

See Also:
Constant Field Values
Constructor Detail

LobbyRegistry

@Inject
public LobbyRegistry(InvocationManager invmgr)
Method Detail

init

public void init()
Initializes the registry, creating our default lobbies.


getDefaultLobbyOid

public int getDefaultLobbyOid()
Returns the oid of the default lobby.


loadLobby

protected void loadLobby(String lobbyId)
Extracts the properties for a lobby from the server config and creates and initializes the lobby manager.


getLobbies

public void getLobbies(BodyObject requester,
                       String category,
                       List<Lobby> target)
Returns information about all lobbies hosting games in the specified category.

Parameters:
requester - the body object of the client requesting the lobby list (which can be used to filter the list based on their capabilities).
category - the category of game for which the lobbies are desired.
target - the list into which the matching lobbies will be deposited.

getCategories

public String[] getCategories(BodyObject requester)
Returns an array containing the category identifiers of all the categories in which lobbies have been registered with the registry.

Parameters:
requester - the body object of the client requesting the category list (which can be used to filter the list based on their capabilities).

getCategories

public void getCategories(ClientObject caller,
                          LobbyService.CategoriesListener listener)
Processes a request by the client to obtain a list of the lobby categories available on this server.

Specified by:
getCategories in interface LobbyProvider

getLobbies

public void getLobbies(ClientObject caller,
                       String category,
                       LobbyService.LobbiesListener listener)
Processes a request by the client to obtain a list of lobbies matching the supplied category string.

Specified by:
getLobbies in interface LobbyProvider

lobbyReady

protected void lobbyReady(int placeOid,
                          String gameIdent,
                          String name)
Called by our lobby managers once they have started up and are ready to do their lobby duties.


registerLobby

protected void registerLobby(String category,
                             Lobby record)
Registers the supplied lobby in the specified category table.