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,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaApplet.java,v 1.6 2002/02/09 20:47:11 mdb Exp $
|
||||
// $Id: MiCasaApplet.java,v 1.7 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -93,7 +93,7 @@ public class MiCasaApplet extends Applet
|
||||
// hide the frame and log off
|
||||
_frame.setVisible(false);
|
||||
Client client = _client.getContext().getClient();
|
||||
if (client.loggedOn()) {
|
||||
if (client.isLoggedOn()) {
|
||||
client.logoff(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaClient.java,v 1.14 2002/07/12 17:01:28 mdb Exp $
|
||||
// $Id: MiCasaClient.java,v 1.15 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.client;
|
||||
|
||||
@@ -55,7 +55,7 @@ public class MiCasaClient
|
||||
_frame.addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing (WindowEvent evt) {
|
||||
// if we're logged on, log off
|
||||
if (_client.loggedOn()) {
|
||||
if (_client.isLoggedOn()) {
|
||||
_client.logoff(true);
|
||||
} else {
|
||||
// otherwise get the heck out
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: MiCasaServer.java,v 1.5 2002/03/28 22:32:32 mdb Exp $
|
||||
// $Id: MiCasaServer.java,v 1.6 2002/08/14 19:07:49 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.server;
|
||||
|
||||
@@ -40,7 +40,7 @@ public class MiCasaServer extends CrowdServer
|
||||
clmgr.setClientClass(MiCasaClient.class);
|
||||
|
||||
// initialize our parlor manager
|
||||
parmgr.init(invmgr);
|
||||
parmgr.init(invmgr, plreg);
|
||||
|
||||
// initialize the lobby registry
|
||||
lobreg.init(invmgr);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ClientController.java,v 1.6 2002/05/17 21:22:46 shaper Exp $
|
||||
// $Id: ClientController.java,v 1.7 2002/08/14 19:07:50 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.client;
|
||||
|
||||
@@ -73,8 +73,11 @@ public class ClientController extends Controller
|
||||
config = (GameConfig)
|
||||
Class.forName(_info.gameConfigClass).newInstance();
|
||||
|
||||
// send the game creation request
|
||||
SimulatorDirector.createGame(
|
||||
// get the simulator service and use it to request that our
|
||||
// game be created
|
||||
SimulatorService sservice = (SimulatorService)
|
||||
client.requireService(SimulatorService.class);
|
||||
sservice.createGame(
|
||||
client, config, _info.simClass, _info.playerCount);
|
||||
|
||||
// our work here is done, as the location manager will move us
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SimpleClient.java,v 1.6 2002/07/15 03:09:29 mdb Exp $
|
||||
// $Id: SimpleClient.java,v 1.7 2002/08/14 19:07:50 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.client;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class SimpleClient
|
||||
_frame.getFrame().addWindowListener(new WindowAdapter() {
|
||||
public void windowClosing (WindowEvent evt) {
|
||||
// if we're logged on, log off
|
||||
if (_client.loggedOn()) {
|
||||
if (_client.isLoggedOn()) {
|
||||
_client.logoff(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// $Id: SimulatorDirector.java,v 1.2 2002/04/15 16:28:02 shaper Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.client;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationDirector;
|
||||
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
|
||||
import com.threerings.micasa.simulator.data.SimulatorCodes;
|
||||
|
||||
public class SimulatorDirector implements SimulatorCodes
|
||||
{
|
||||
/**
|
||||
* Requests that a new game be created.
|
||||
*
|
||||
* @param client a connected, operational client instance.
|
||||
* @param config the game config for the game to be created.
|
||||
* @param simClass the class name of the simulant to create.
|
||||
* @param playerCount the number of players in the game.
|
||||
*
|
||||
* @return the invocation request id of the generated request.
|
||||
*/
|
||||
public static int createGame (
|
||||
Client client, GameConfig config, String simClass, int playerCount)
|
||||
{
|
||||
InvocationDirector invdir = client.getInvocationDirector();
|
||||
Object[] args = new Object[] {
|
||||
config, simClass, new Integer(playerCount) };
|
||||
return invdir.invoke(MODULE_NAME, CREATE_GAME_REQUEST, args, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// $Id: SimulatorService.java,v 1.1 2002/08/14 19:07:50 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.client;
|
||||
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.client.InvocationService;
|
||||
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
|
||||
/**
|
||||
* Provides access to simulator invocation services.
|
||||
*/
|
||||
public interface SimulatorService extends InvocationService
|
||||
{
|
||||
/**
|
||||
* Requests that a new game be created.
|
||||
*
|
||||
* @param client a connected, operational client instance.
|
||||
* @param config the game config for the game to be created.
|
||||
* @param simClass the class name of the simulant to create.
|
||||
* @param playerCount the number of players in the game.
|
||||
*/
|
||||
public void createGame (Client client, GameConfig config,
|
||||
String simClass, int playerCount);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
//
|
||||
// $Id: SimulatorCodes.java,v 1.1 2002/04/15 16:28:02 shaper Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.data;
|
||||
|
||||
public interface SimulatorCodes
|
||||
{
|
||||
/** The module name for the simulator services. */
|
||||
public static final String MODULE_NAME = "simulator";
|
||||
|
||||
/** The message identifier for a create table request. */
|
||||
public static final String CREATE_GAME_REQUEST = "CreateGame";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// $Id: SimulatorMarshaller.java,v 1.1 2002/08/14 19:07:51 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.data;
|
||||
|
||||
import com.threerings.micasa.simulator.client.SimulatorService;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.presents.client.Client;
|
||||
import com.threerings.presents.data.InvocationMarshaller;
|
||||
import com.threerings.presents.dobj.InvocationResponseEvent;
|
||||
|
||||
/**
|
||||
* Provides the implementation of the {@link SimulatorService} 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 SimulatorMarshaller extends InvocationMarshaller
|
||||
implements SimulatorService
|
||||
{
|
||||
/** The method id used to dispatch {@link #createGame} requests. */
|
||||
public static final int CREATE_GAME = 1;
|
||||
|
||||
// documentation inherited from interface
|
||||
public void createGame (Client arg1, GameConfig arg2, String arg3, int arg4)
|
||||
{
|
||||
sendRequest(arg1, CREATE_GAME, new Object[] {
|
||||
arg2, arg3, new Integer(arg4)
|
||||
});
|
||||
}
|
||||
|
||||
// Class file generated on 00:26:00 08/11/02.
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// $Id: Simulant.java,v 1.3 2002/02/05 22:11:51 mdb Exp $
|
||||
// $Id: Simulant.java,v 1.4 2002/08/14 19:07:51 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.client;
|
||||
package com.threerings.micasa.simulator.server;
|
||||
|
||||
import com.threerings.presents.dobj.DObjectManager;
|
||||
import com.threerings.presents.dobj.MessageEvent;
|
||||
@@ -9,19 +9,21 @@ import com.threerings.presents.dobj.MessageEvent;
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
|
||||
import com.threerings.parlor.game.GameCodes;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.parlor.game.GameManager;
|
||||
|
||||
public abstract class Simulant implements GameCodes
|
||||
public abstract class Simulant
|
||||
{
|
||||
/**
|
||||
* Initializes the simulant with a body object and the game config for
|
||||
* the game they'll be engaged in.
|
||||
*/
|
||||
public void init (BodyObject self, GameConfig config, DObjectManager omgr)
|
||||
public void init (BodyObject self, GameConfig config,
|
||||
GameManager gmgr, DObjectManager omgr)
|
||||
{
|
||||
_self = self;
|
||||
_config = config;
|
||||
_gmgr = gmgr;
|
||||
_omgr = omgr;
|
||||
}
|
||||
|
||||
@@ -37,9 +39,7 @@ public abstract class Simulant implements GameCodes
|
||||
public void willEnterPlace (PlaceObject plobj)
|
||||
{
|
||||
// let the game manager know that the simulant's ready
|
||||
MessageEvent mevt = new MessageEvent(
|
||||
plobj.getOid(), PLAYER_READY_NOTIFICATION, null);
|
||||
postEvent(mevt);
|
||||
_gmgr.playerReady(_self);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,6 +59,9 @@ public abstract class Simulant implements GameCodes
|
||||
/** The game config object. */
|
||||
protected GameConfig _config;
|
||||
|
||||
/** The game manager for the game we're playing. */
|
||||
protected GameManager _gmgr;
|
||||
|
||||
/** Our body object. */
|
||||
protected BodyObject _self;
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// $Id: SimulatorDispatcher.java,v 1.1 2002/08/14 19:07:51 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.server;
|
||||
|
||||
import com.threerings.micasa.simulator.client.SimulatorService;
|
||||
import com.threerings.micasa.simulator.data.SimulatorMarshaller;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Dispatches requests to the {@link SimulatorProvider}.
|
||||
*/
|
||||
public class SimulatorDispatcher extends InvocationDispatcher
|
||||
{
|
||||
/**
|
||||
* Creates a dispatcher that may be registered to dispatch invocation
|
||||
* service requests for the specified provider.
|
||||
*/
|
||||
public SimulatorDispatcher (SimulatorProvider provider)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public InvocationMarshaller createMarshaller ()
|
||||
{
|
||||
return new SimulatorMarshaller();
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void dispatchRequest (
|
||||
ClientObject source, int methodId, Object[] args)
|
||||
throws InvocationException
|
||||
{
|
||||
switch (methodId) {
|
||||
case SimulatorMarshaller.CREATE_GAME:
|
||||
((SimulatorProvider)provider).createGame(
|
||||
source,
|
||||
(GameConfig)args[0], (String)args[1], ((Integer)args[2]).intValue()
|
||||
);
|
||||
return;
|
||||
|
||||
default:
|
||||
super.dispatchRequest(source, methodId, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: SimulatorManager.java,v 1.11 2002/07/02 21:14:23 shaper Exp $
|
||||
// $Id: SimulatorManager.java,v 1.12 2002/08/14 19:07:51 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.server;
|
||||
|
||||
@@ -14,25 +14,21 @@ import com.threerings.presents.server.InvocationProvider;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.crowd.data.PlaceObject;
|
||||
import com.threerings.crowd.server.LocationProvider;
|
||||
import com.threerings.crowd.server.PlaceManager;
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
import com.threerings.crowd.server.PlaceRegistry.CreationObserver;
|
||||
import com.threerings.crowd.server.PlaceRegistry;
|
||||
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
import com.threerings.parlor.game.GameManager;
|
||||
import com.threerings.parlor.game.GameObject;
|
||||
|
||||
import com.threerings.micasa.Log;
|
||||
import com.threerings.micasa.simulator.client.Simulant;
|
||||
import com.threerings.micasa.simulator.data.SimulatorCodes;
|
||||
|
||||
/**
|
||||
* The simulator manager is responsible for handling the simulator
|
||||
* services on the server side.
|
||||
*/
|
||||
public class SimulatorManager
|
||||
implements SimulatorCodes
|
||||
{
|
||||
/**
|
||||
* Initializes the simulator manager manager. This should be called by
|
||||
@@ -48,7 +44,7 @@ public class SimulatorManager
|
||||
{
|
||||
// register our simulator provider
|
||||
SimulatorProvider sprov = new SimulatorProvider(this);
|
||||
invmgr.registerProvider(MODULE_NAME, sprov);
|
||||
invmgr.registerDispatcher(new SimulatorDispatcher(sprov), true);
|
||||
|
||||
// keep these for later
|
||||
_plreg = plreg;
|
||||
@@ -172,7 +168,7 @@ public class SimulatorManager
|
||||
|
||||
// give the simulant its body
|
||||
BodyObject bobj = (BodyObject)_sims.get(ii - 1);
|
||||
sim.init(bobj, _config, _omgr);
|
||||
sim.init(bobj, _config, _gmgr, _omgr);
|
||||
|
||||
// give the simulant a chance to engage in place antics
|
||||
sim.willEnterPlace(_gobj);
|
||||
@@ -180,7 +176,7 @@ public class SimulatorManager
|
||||
// move the simulant into the game room since they have no
|
||||
// location director to move them automagically
|
||||
try {
|
||||
LocationProvider.moveTo(bobj, _gobj.getOid());
|
||||
_plreg.locprov.moveTo(bobj, _gobj.getOid());
|
||||
} catch (Exception e) {
|
||||
Log.warning("Failed to move simulant into room " +
|
||||
"[e=" + e + "].");
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
//
|
||||
// $Id: SimulatorProvider.java,v 1.1 2001/12/19 09:32:02 shaper Exp $
|
||||
// $Id: SimulatorProvider.java,v 1.2 2002/08/14 19:07:51 mdb Exp $
|
||||
|
||||
package com.threerings.micasa.simulator.server;
|
||||
|
||||
import com.threerings.presents.data.ClientObject;
|
||||
import com.threerings.presents.server.InvocationProvider;
|
||||
|
||||
import com.threerings.crowd.data.BodyObject;
|
||||
import com.threerings.parlor.game.GameConfig;
|
||||
|
||||
@@ -14,7 +16,7 @@ import com.threerings.micasa.Log;
|
||||
* side, passing them off to the {@link SimulatorManager}.
|
||||
*/
|
||||
public class SimulatorProvider
|
||||
extends InvocationProvider
|
||||
implements InvocationProvider
|
||||
{
|
||||
/**
|
||||
* Constructs a simulator provider.
|
||||
@@ -27,15 +29,14 @@ public class SimulatorProvider
|
||||
/**
|
||||
* Processes a request from the client to create a new game.
|
||||
*/
|
||||
public void handleCreateGameRequest (
|
||||
BodyObject source, int invid, GameConfig config,
|
||||
String simClass, int playerCount)
|
||||
public void createGame (ClientObject caller, GameConfig config,
|
||||
String simClass, int playerCount)
|
||||
{
|
||||
Log.info("handleCreateGameRequest [source=" + source +
|
||||
Log.info("handleCreateGameRequest [caller=" + caller +
|
||||
", config=" + config + ", simClass=" + simClass +
|
||||
", playerCount=" + playerCount + "].");
|
||||
|
||||
_simmgr.createGame(source, config, simClass, playerCount);
|
||||
_simmgr.createGame((BodyObject)caller, config, simClass, playerCount);
|
||||
}
|
||||
|
||||
/** The simulator manager. */
|
||||
|
||||
Reference in New Issue
Block a user