The great invocation services rethink of 2002! Rearchitected the remote
method invocation services and converted everything to the new style. Could this be my biggest checkin ever? git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1642 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// $Id: LobbyCodes.java,v 1.4 2002/04/15 16:28:02 shaper Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import com.threerings.presents.data.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 categories request. */
|
||||
public static final String GET_CATEGORIES_REQUEST = "GetCategories";
|
||||
|
||||
/** The message identifier for a got categories response. This is
|
||||
* mapped by the invocation services to a call to
|
||||
* <code>handleGotCategories</code>. */
|
||||
public static final String GOT_CATEGORIES_RESPONSE = "GotCategories";
|
||||
|
||||
/** The message identifier for a get lobbies request. */
|
||||
public static final String GET_LOBBIES_REQUEST = "GetLobbies";
|
||||
|
||||
/** The message identifier for a got lobbies response. This is mapped
|
||||
* by the invocation services to a call to
|
||||
* <code>handleGotLobbies</code>. */
|
||||
public static final String GOT_LOBBIES_RESPONSE = "GotLobbies";
|
||||
|
||||
/** The message identifier for a failed request. This is
|
||||
* mapped by the invocation services to a call to
|
||||
* <code>handleRequestFailed</code>. */
|
||||
public static final String REQUEST_FAILED_RESPONSE = "RequestFailed";
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: LobbyController.java,v 1.8 2001/10/25 23:42:33 mdb Exp $
|
||||
// $Id: LobbyController.java,v 1.9 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
@@ -15,8 +15,7 @@ import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.micasa.Log;
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
|
||||
public class LobbyController
|
||||
extends PlaceController
|
||||
public class LobbyController extends PlaceController
|
||||
implements InvitationHandler, InvitationResponseObserver
|
||||
{
|
||||
public void init (CrowdContext ctx, PlaceConfig config)
|
||||
@@ -61,35 +60,38 @@ public class LobbyController
|
||||
}
|
||||
}
|
||||
|
||||
public void invitationReceived (int inviteId, String inviter,
|
||||
GameConfig config)
|
||||
// documentation inherited from interface
|
||||
public void invitationReceived (Invitation invite)
|
||||
{
|
||||
Log.info("Invitation received [inviteId=" + inviteId +
|
||||
", inviter=" + inviter + ", config=" + config + "].");
|
||||
Log.info("Invitation received [invite=" + invite + "].");
|
||||
|
||||
// accept the invitation. we're game...
|
||||
_ctx.getParlorDirector().accept(inviteId);
|
||||
invite.accept();
|
||||
}
|
||||
|
||||
public void invitationCancelled (int inviteId)
|
||||
// documentation inherited from interface
|
||||
public void invitationCancelled (Invitation invite)
|
||||
{
|
||||
Log.info("Invitation cancelled [inviteId=" + inviteId + "].");
|
||||
Log.info("Invitation cancelled " + invite + ".");
|
||||
}
|
||||
|
||||
public void invitationAccepted (int inviteId)
|
||||
// documentation inherited from interface
|
||||
public void invitationAccepted (Invitation invite)
|
||||
{
|
||||
Log.info("Invitation accepted [inviteId=" + inviteId + "].");
|
||||
Log.info("Invitation accepted " + invite + ".");
|
||||
}
|
||||
|
||||
public void invitationRefused (int inviteId, String message)
|
||||
// documentation inherited from interface
|
||||
public void invitationRefused (Invitation invite, String message)
|
||||
{
|
||||
Log.info("Invitation refused [inviteId=" + inviteId +
|
||||
Log.info("Invitation refused [invite=" + invite +
|
||||
", message=" + message + "].");
|
||||
}
|
||||
|
||||
public void invitationCountered (int inviteId, GameConfig config)
|
||||
// documentation inherited from interface
|
||||
public void invitationCountered (Invitation invite, GameConfig config)
|
||||
{
|
||||
Log.info("Invitation countered [inviteId=" + inviteId +
|
||||
Log.info("Invitation countered [invite=" + invite +
|
||||
", config=" + config + "].");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// $Id: LobbyDispatcher.java,v 1.1 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import com.threerings.micasa.lobby.LobbyMarshaller;
|
||||
import com.threerings.micasa.lobby.LobbyService;
|
||||
import com.threerings.micasa.lobby.LobbyService.CategoriesListener;
|
||||
import com.threerings.micasa.lobby.LobbyService.LobbiesListener;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.server.InvocationDispatcher;
|
||||
import com.threerings.presents.server.InvocationException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Dispatches requests to the {@link LobbyProvider}.
|
||||
*/
|
||||
public class LobbyDispatcher extends InvocationDispatcher
|
||||
{
|
||||
/**
|
||||
* Creates a dispatcher that may be registered to dispatch invocation
|
||||
* service requests for the specified provider.
|
||||
*/
|
||||
public LobbyDispatcher (LobbyProvider provider)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public InvocationMarshaller createMarshaller ()
|
||||
{
|
||||
return new LobbyMarshaller();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchRequest (
|
||||
ClientObject source, int methodId, Object[] args)
|
||||
throws InvocationException
|
||||
{
|
||||
switch (methodId) {
|
||||
case LobbyMarshaller.GET_CATEGORIES:
|
||||
((LobbyProvider)provider).getCategories(
|
||||
source,
|
||||
(CategoriesListener)args[0]
|
||||
);
|
||||
return;
|
||||
|
||||
case LobbyMarshaller.GET_LOBBIES:
|
||||
((LobbyProvider)provider).getLobbies(
|
||||
source,
|
||||
(String)args[0], (LobbiesListener)args[1]
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
//
|
||||
// $Id: LobbyManager.java,v 1.4 2001/10/11 04:13:33 mdb Exp $
|
||||
// $Id: LobbyManager.java,v 1.5 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import java.util.Properties;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.threerings.crowd.chat.ChatService;
|
||||
import com.threerings.crowd.chat.ChatMessageHandler;
|
||||
import com.threerings.crowd.chat.ChatCodes;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.micasa.Log;
|
||||
|
||||
@@ -61,11 +60,6 @@ public class LobbyManager extends PlaceManager
|
||||
|
||||
// let the lobby registry know that we're up and running
|
||||
_lobreg.lobbyReady(_plobj.getOid(), _gameIdent, _name);
|
||||
|
||||
// register a chat message handler because we want to support
|
||||
// chatting
|
||||
MessageHandler handler = new ChatMessageHandler();
|
||||
registerMessageHandler(ChatService.SPEAK_REQUEST, handler);
|
||||
}
|
||||
|
||||
/** The universal game identifier for the game matchmade by this
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
//
|
||||
// $Id: LobbyMarshaller.java,v 1.1 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import com.threerings.micasa.lobby.LobbyService;
|
||||
import com.threerings.micasa.lobby.LobbyService.CategoriesListener;
|
||||
import com.threerings.micasa.lobby.LobbyService.LobbiesListener;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.dobj.InvocationResponseEvent;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides the implementation of the {@link LobbyService} interface
|
||||
* that marshalls the arguments and delivers the request to the provider
|
||||
* on the server. Also provides an implementation of the response listener
|
||||
* interfaces that marshall the response arguments and deliver them back
|
||||
* to the requesting client.
|
||||
*/
|
||||
public class LobbyMarshaller extends InvocationMarshaller
|
||||
implements LobbyService
|
||||
{
|
||||
// documentation inherited
|
||||
public static class CategoriesMarshaller extends ListenerMarshaller
|
||||
implements CategoriesListener
|
||||
{
|
||||
/** The method id used to dispatch {@link #gotCategories}
|
||||
* responses. */
|
||||
public static final int GOT_CATEGORIES = 0;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void gotCategories (String[] arg1)
|
||||
{
|
||||
omgr.postEvent(new InvocationResponseEvent(
|
||||
callerOid, requestId, GOT_CATEGORIES,
|
||||
new Object[] { arg1 }));
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchResponse (int methodId, Object[] args)
|
||||
{
|
||||
switch (methodId) {
|
||||
case GOT_CATEGORIES:
|
||||
((CategoriesListener)listener).gotCategories(
|
||||
(String[])args[0]);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchResponse(methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public static class LobbiesMarshaller extends ListenerMarshaller
|
||||
implements LobbiesListener
|
||||
{
|
||||
/** The method id used to dispatch {@link #gotLobbies}
|
||||
* responses. */
|
||||
public static final int GOT_LOBBIES = 0;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void gotLobbies (List arg1)
|
||||
{
|
||||
omgr.postEvent(new InvocationResponseEvent(
|
||||
callerOid, requestId, GOT_LOBBIES,
|
||||
new Object[] { arg1 }));
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchResponse (int methodId, Object[] args)
|
||||
{
|
||||
switch (methodId) {
|
||||
case GOT_LOBBIES:
|
||||
((LobbiesListener)listener).gotLobbies(
|
||||
(List)args[0]);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchResponse(methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #getCategories} requests. */
|
||||
public static final int GET_CATEGORIES = 1;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void getCategories (Client arg1, CategoriesListener arg2)
|
||||
{
|
||||
CategoriesMarshaller listener2 = new CategoriesMarshaller();
|
||||
listener2.listener = arg2;
|
||||
sendRequest(arg1, GET_CATEGORIES, new Object[] {
|
||||
listener2
|
||||
});
|
||||
}
|
||||
|
||||
/** The method id used to dispatch {@link #getLobbies} requests. */
|
||||
public static final int GET_LOBBIES = 2;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void getLobbies (Client arg1, String arg2, LobbiesListener arg3)
|
||||
{
|
||||
LobbiesMarshaller listener3 = new LobbiesMarshaller();
|
||||
listener3.listener = arg3;
|
||||
sendRequest(arg1, GET_LOBBIES, new Object[] {
|
||||
arg2, listener3
|
||||
});
|
||||
}
|
||||
|
||||
// Class file generated on 00:26:00 08/11/02.
|
||||
}
|
||||
@@ -1,57 +1,31 @@
|
||||
//
|
||||
// $Id: LobbyProvider.java,v 1.4 2002/07/23 05:54:52 mdb Exp $
|
||||
// $Id: LobbyProvider.java,v 1.5 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.server.InvocationProvider;
|
||||
import com.threerings.util.StreamableArrayList;
|
||||
|
||||
import com.threerings.micasa.lobby.LobbyService.CategoriesListener;
|
||||
import com.threerings.micasa.lobby.LobbyService.LobbiesListener;
|
||||
|
||||
/**
|
||||
* Handles server side of lobby-related invocation services.
|
||||
* Provides access to the server-side implementation of the lobby
|
||||
* services.
|
||||
*/
|
||||
public class LobbyProvider
|
||||
extends InvocationProvider implements LobbyCodes
|
||||
public interface LobbyProvider extends InvocationProvider
|
||||
{
|
||||
/**
|
||||
* 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 the lobby
|
||||
* categories available on this server.
|
||||
*/
|
||||
public void handleGetCategoriesRequest (
|
||||
BodyObject source, int invid)
|
||||
{
|
||||
String[] cats = _lobreg.getCategories(source);
|
||||
// we have to cast the array to an object to avoid having the
|
||||
// compiler pick the version of sendResponse that takes Object[]
|
||||
sendResponse(source, invid, GOT_CATEGORIES_RESPONSE, (Object)cats);
|
||||
}
|
||||
public void getCategories (ClientObject caller,
|
||||
CategoriesListener listener);
|
||||
|
||||
/**
|
||||
* Processes a request by the client to obtain a list of lobbies
|
||||
* matching the supplied category string.
|
||||
*/
|
||||
public void handleGetLobbiesRequest (
|
||||
BodyObject source, int invid, String category)
|
||||
{
|
||||
StreamableArrayList list = new StreamableArrayList();
|
||||
_lobreg.getLobbies(source, category, list);
|
||||
sendResponse(source, invid, GOT_LOBBIES_RESPONSE, list);
|
||||
}
|
||||
|
||||
/** A reference to the lobby registry. */
|
||||
protected LobbyRegistry _lobreg;
|
||||
public void getLobbies (ClientObject caller, String category,
|
||||
LobbiesListener listener);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
//
|
||||
// $Id: LobbyRegistry.java,v 1.9 2002/05/21 04:46:44 mdb Exp $
|
||||
// $Id: LobbyRegistry.java,v 1.10 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import java.util.*;
|
||||
import com.samskivert.util.*;
|
||||
import com.threerings.util.StreamableArrayList;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.server.InvocationManager;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
import com.threerings.micasa.lobby.LobbyService.CategoriesListener;
|
||||
import com.threerings.micasa.lobby.LobbyService.LobbiesListener;
|
||||
import com.threerings.micasa.server.MiCasaConfig;
|
||||
import com.threerings.micasa.server.MiCasaServer;
|
||||
|
||||
@@ -64,7 +69,8 @@ import com.threerings.micasa.server.MiCasaServer;
|
||||
* 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 LobbyCodes
|
||||
public class LobbyRegistry
|
||||
implements LobbyProvider
|
||||
{
|
||||
/**
|
||||
* Initializes the registry. It will use the supplied configuration
|
||||
@@ -75,9 +81,8 @@ public class LobbyRegistry implements LobbyCodes
|
||||
*/
|
||||
public void init (InvocationManager invmgr)
|
||||
{
|
||||
// register our invocation service handler
|
||||
LobbyProvider provider = new LobbyProvider(this);
|
||||
invmgr.registerProvider(MODULE_NAME, provider);
|
||||
// register ourselves as an invocation service handler
|
||||
invmgr.registerDispatcher(new LobbyDispatcher(this), true);
|
||||
|
||||
// create our lobby managers
|
||||
String[] lmgrs = null;
|
||||
@@ -178,6 +183,30 @@ public class LobbyRegistry implements LobbyCodes
|
||||
return cats;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
listener.gotCategories(getCategories((BodyObject)caller));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
StreamableArrayList target = new StreamableArrayList();
|
||||
ArrayList list = (ArrayList)_lobbies.get(category);
|
||||
if (list != null) {
|
||||
target.addAll(list);
|
||||
}
|
||||
listener.gotLobbies(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by our lobby managers once they have started up and are
|
||||
* ready to do their lobby duties.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: LobbySelector.java,v 1.4 2001/12/14 16:07:30 shaper Exp $
|
||||
// $Id: LobbySelector.java,v 1.5 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
@@ -18,8 +18,6 @@ import com.samskivert.util.StringUtil;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
import com.threerings.micasa.lobby.Lobby;
|
||||
import com.threerings.micasa.lobby.LobbyService;
|
||||
import com.threerings.micasa.util.MiCasaContext;
|
||||
|
||||
/**
|
||||
@@ -28,8 +26,9 @@ import com.threerings.micasa.util.MiCasaContext;
|
||||
* displays a list of the lobbies that are available in that category. If
|
||||
* a lobby is double-clicked, it moves the client into that lobby room.
|
||||
*/
|
||||
public class LobbySelector
|
||||
extends JPanel implements ActionListener
|
||||
public class LobbySelector extends JPanel
|
||||
implements ActionListener, LobbyService.CategoriesListener,
|
||||
LobbyService.LobbiesListener
|
||||
{
|
||||
/**
|
||||
* Constructs a new lobby selector component. It will wait until it is
|
||||
@@ -64,16 +63,18 @@ public class LobbySelector
|
||||
};
|
||||
_loblist.addMouseListener(ml);
|
||||
add(_loblist, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
// we'll need to know when we are made visible because we'll want
|
||||
// to issue a request for our categories when that happens
|
||||
addAncestorListener(new AncestorAdapter () {
|
||||
public void ancestorAdded (AncestorEvent evt) {
|
||||
// issue a get categories request to get the category list
|
||||
LobbyService.getCategories(
|
||||
_ctx.getClient(), LobbySelector.this);
|
||||
}
|
||||
});
|
||||
// documentation inherited
|
||||
public void addNotify ()
|
||||
{
|
||||
super.addNotify();
|
||||
|
||||
// get a handle on our lobby service instance
|
||||
_lservice = (LobbyService)
|
||||
_ctx.getClient().requireService(LobbyService.class);
|
||||
// and use them to look up the lobby categories
|
||||
_lservice.getCategories(_ctx.getClient(), this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,11 +91,8 @@ public class LobbySelector
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in response to a {@link LobbyService#getCategories}
|
||||
* invocation service request.
|
||||
*/
|
||||
public void handleGotCategories (int invid, String[] categories)
|
||||
// documentation inherited from interface
|
||||
public void gotCategories (String[] categories)
|
||||
{
|
||||
// append these to our "unselected" item
|
||||
for (int i = 0; i < categories.length; i++) {
|
||||
@@ -102,11 +100,8 @@ public class LobbySelector
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in response to a {@link LobbyService#getLobbies} invocation
|
||||
* service request.
|
||||
*/
|
||||
public void handleGotLobbies (int invid, List lobbies)
|
||||
// documentation inherited from interface
|
||||
public void gotLobbies (List lobbies)
|
||||
{
|
||||
// create a list model for this category
|
||||
DefaultListModel model = new DefaultListModel();
|
||||
@@ -130,16 +125,13 @@ public class LobbySelector
|
||||
_pendingCategory = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called in response to a lobby invocation request when the request
|
||||
* failed.
|
||||
*/
|
||||
public void handleRequestFailed (int invid, String reason)
|
||||
// documentation inherited from interface
|
||||
public void requestFailed (String reason)
|
||||
{
|
||||
Log.info("Request failed [invid=" + invid +
|
||||
", reason=" + reason + "].");
|
||||
Log.info("Request failed [reason=" + reason + "].");
|
||||
|
||||
// clear out our pending category indicator
|
||||
// clear out our pending category indicator in case this was a
|
||||
// failed getLobbies() request
|
||||
_pendingCategory = null;
|
||||
}
|
||||
|
||||
@@ -158,7 +150,7 @@ public class LobbySelector
|
||||
// make a note that we're loading up this category
|
||||
_pendingCategory = category;
|
||||
// issue a request to load up the lobbies in this category
|
||||
LobbyService.getLobbies(_ctx.getClient(), category, this);
|
||||
_lservice.getLobbies(_ctx.getClient(), category, this);
|
||||
|
||||
} else {
|
||||
Log.info("Ignoring category select request because " +
|
||||
@@ -201,6 +193,8 @@ public class LobbySelector
|
||||
}
|
||||
|
||||
protected MiCasaContext _ctx;
|
||||
protected LobbyService _lservice;
|
||||
|
||||
protected JComboBox _combo;
|
||||
protected JList _loblist;
|
||||
|
||||
|
||||
@@ -1,40 +1,54 @@
|
||||
//
|
||||
// $Id: LobbyService.java,v 1.3 2002/05/15 23:54:34 mdb Exp $
|
||||
// $Id: LobbyService.java,v 1.4 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.lobby;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationDirector;
|
||||
import java.util.List;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
|
||||
/**
|
||||
* This class provides an interface to the various parlor services that
|
||||
* are directly invokable by the client (by means of the invocation
|
||||
* services).
|
||||
* Provides an interface to the various parlor services that are directly
|
||||
* invokable by the client (by means of the invocation services).
|
||||
*/
|
||||
public class LobbyService
|
||||
implements LobbyCodes
|
||||
public interface LobbyService extends InvocationService
|
||||
{
|
||||
/**
|
||||
* Used to communicate the results of a {@link #getCategories}
|
||||
* request.
|
||||
*/
|
||||
public static interface CategoriesListener extends InvocationListener
|
||||
{
|
||||
/**
|
||||
* Supplies the listener with the results of a {@link
|
||||
* #getCategories} request.
|
||||
*/
|
||||
public void gotCategories (String[] categories);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to communicate the results of a {@link #getLobbies}
|
||||
* request.
|
||||
*/
|
||||
public static interface LobbiesListener extends InvocationListener
|
||||
{
|
||||
/**
|
||||
* Supplies the listener with the results of a {@link
|
||||
* #getLobbies} request.
|
||||
*/
|
||||
public void gotLobbies (List lobbies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests the list of lobby cateogories that are available on this
|
||||
* server.
|
||||
*
|
||||
* @param client a connected, operational client instance.
|
||||
* @param rsptarget the object reference that will receive and process
|
||||
* the response. The response will come in the form of a method call
|
||||
* to <code>handleGotCategories</code> or
|
||||
* <code>handleRequestFailed</code>.
|
||||
*
|
||||
* @return the invocation request id of the generated request.
|
||||
* @param listener the listener that will receive and process the
|
||||
* response.
|
||||
*/
|
||||
public static int getCategories (Client client, Object rsptarget)
|
||||
{
|
||||
InvocationDirector invdir = client.getInvocationDirector();
|
||||
Log.debug("Sending get categories.");
|
||||
return invdir.invoke(
|
||||
MODULE_NAME, GET_CATEGORIES_REQUEST, null, rsptarget);
|
||||
}
|
||||
public void getCategories (Client client, CategoriesListener listener);
|
||||
|
||||
/**
|
||||
* Requests information on all active lobbies that match the specified
|
||||
@@ -43,20 +57,9 @@ public class LobbyService
|
||||
* @param client a connected, operational client instance.
|
||||
* @param category the category of game for which a list of lobbies is
|
||||
* desired.
|
||||
* @param rsptarget the object reference that will receive and process
|
||||
* the response. The response will come in the form of a method call
|
||||
* to <code>handleLobbyList</code> or
|
||||
* <code>handleRequestFailed</code>.
|
||||
*
|
||||
* @return the invocation request id of the generated request.
|
||||
* @param listener the listener that will receive and process the
|
||||
* response.
|
||||
*/
|
||||
public static int getLobbies (
|
||||
Client client, String category, Object rsptarget)
|
||||
{
|
||||
InvocationDirector invdir = client.getInvocationDirector();
|
||||
Object[] args = new Object[] { category };
|
||||
Log.debug("Sending get lobbies [category=" + category + "].");
|
||||
return invdir.invoke(
|
||||
MODULE_NAME, GET_LOBBIES_REQUEST, args, rsptarget);
|
||||
}
|
||||
public void getLobbies (Client client, String category,
|
||||
LobbiesListener listener);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user