Created fooCodes interfaces to go along with invocation service
packages. These contain all the message codes as well as error response codes that are used by a particular invocation service. Also changed client.LocationManager to client.LocationDirector and chat.ChatManager to chat.ChatDirector to go along with the new philosophy of naming the client-side managing entity for an invocation service a director. Also elimitated cocktail.util.Codes since it's no longer used as a central repository for codes (instead they are in InvocationCodes and its derivatives). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@368 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ChatDirector.java,v 1.6 2001/08/22 00:08:39 mdb Exp $
|
// $Id: ChatDirector.java,v 1.7 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.chat;
|
package com.threerings.cocktail.party.chat;
|
||||||
|
|
||||||
@@ -7,7 +7,6 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import com.threerings.cocktail.cher.client.*;
|
import com.threerings.cocktail.cher.client.*;
|
||||||
import com.threerings.cocktail.cher.dobj.*;
|
import com.threerings.cocktail.cher.dobj.*;
|
||||||
import com.threerings.cocktail.cher.util.Codes;
|
|
||||||
|
|
||||||
import com.threerings.cocktail.party.Log;
|
import com.threerings.cocktail.party.Log;
|
||||||
import com.threerings.cocktail.party.client.LocationObserver;
|
import com.threerings.cocktail.party.client.LocationObserver;
|
||||||
@@ -15,20 +14,20 @@ import com.threerings.cocktail.party.data.PlaceObject;
|
|||||||
import com.threerings.cocktail.party.util.PartyContext;
|
import com.threerings.cocktail.party.util.PartyContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The chat manager is the client side coordinator of all chat related
|
* The chat director is the client side coordinator of all chat related
|
||||||
* services. It handles both place constrainted chat as well as direct
|
* services. It handles both place constrainted chat as well as direct
|
||||||
* messaging.
|
* messaging.
|
||||||
*/
|
*/
|
||||||
public class ChatManager
|
public class ChatDirector
|
||||||
implements LocationObserver, Subscriber, InvocationReceiver
|
implements LocationObserver, Subscriber, InvocationReceiver, ChatCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a chat manager and initializes it with the supplied
|
* Creates a chat director and initializes it with the supplied
|
||||||
* context. The chat manager will register itself as a location
|
* context. The chat director will register itself as a location
|
||||||
* observer so that it can automatically process place constrained
|
* observer so that it can automatically process place constrained
|
||||||
* chat.
|
* chat.
|
||||||
*/
|
*/
|
||||||
public ChatManager (PartyContext ctx)
|
public ChatDirector (PartyContext ctx)
|
||||||
{
|
{
|
||||||
// keep the context around
|
// keep the context around
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
@@ -39,12 +38,12 @@ public class ChatManager
|
|||||||
public void clientDidLogon (Client client)
|
public void clientDidLogon (Client client)
|
||||||
{
|
{
|
||||||
client.getInvocationManager().registerReceiver(
|
client.getInvocationManager().registerReceiver(
|
||||||
ChatService.MODULE, ChatManager.this);
|
MODULE_NAME, ChatDirector.this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// register ourselves as a location observer
|
// register ourselves as a location observer
|
||||||
_ctx.getLocationManager().addLocationObserver(this);
|
_ctx.getLocationDirector().addLocationObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -183,7 +182,7 @@ public class ChatManager
|
|||||||
// pass this on to our chat displays
|
// pass this on to our chat displays
|
||||||
for (int i = 0; i < _displays.size(); i++) {
|
for (int i = 0; i < _displays.size(); i++) {
|
||||||
ChatDisplay display = (ChatDisplay)_displays.get(i);
|
ChatDisplay display = (ChatDisplay)_displays.get(i);
|
||||||
display.handleResponse(invid, Codes.SUCCESS);
|
display.handleResponse(invid, SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ChatDisplay.java,v 1.1 2001/08/02 23:46:47 mdb Exp $
|
// $Id: ChatDisplay.java,v 1.2 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.chat;
|
package com.threerings.cocktail.party.chat;
|
||||||
|
|
||||||
@@ -36,10 +36,9 @@ public interface ChatDisplay
|
|||||||
* Called in response to a chat request (either speak or tell) that
|
* Called in response to a chat request (either speak or tell) that
|
||||||
* originated on this client. The request id supplied will match the
|
* originated on this client. The request id supplied will match the
|
||||||
* one returned when the request was generated and the status will
|
* one returned when the request was generated and the status will
|
||||||
* either indicate success (by being equal to
|
* either indicate success (by being equal to <code>SUCCESS</code>) or
|
||||||
* <code>Codes.SUCCESS</code>) or failure (in which case it will
|
* failure (in which case it will contain a message failure code which
|
||||||
* contain a message failure code which can be converted into a
|
* can be converted into a displayable string).
|
||||||
* displayable string).
|
|
||||||
*
|
*
|
||||||
* <p> A chat display should track outstanding chat requests so that
|
* <p> A chat display should track outstanding chat requests so that
|
||||||
* it can properly handle the response when it arrives.
|
* it can properly handle the response when it arrives.
|
||||||
@@ -49,8 +48,8 @@ public interface ChatDisplay
|
|||||||
* @param status the message code indicating whether the chat request
|
* @param status the message code indicating whether the chat request
|
||||||
* was successful or not.
|
* was successful or not.
|
||||||
*
|
*
|
||||||
* @see ChatManager#requestSpeak
|
* @see ChatDirector#requestSpeak
|
||||||
* @see ChatManager#requestTell
|
* @see ChatDirector#requestTell
|
||||||
*/
|
*/
|
||||||
public void handleResponse (int reqid, String status);
|
public void handleResponse (int reqid, String status);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ChatService.java,v 1.3 2001/08/04 02:54:28 mdb Exp $
|
// $Id: ChatService.java,v 1.4 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.chat;
|
package com.threerings.cocktail.party.chat;
|
||||||
|
|
||||||
@@ -11,27 +11,12 @@ import com.threerings.cocktail.party.Log;
|
|||||||
* The chat services provide a mechanism by which the client can broadcast
|
* The chat services provide a mechanism by which the client can broadcast
|
||||||
* chat messages to all clients that are subscribed to a particular place
|
* chat messages to all clients that are subscribed to a particular place
|
||||||
* object or directly to a particular client. These services should not be
|
* object or directly to a particular client. These services should not be
|
||||||
* used directly, but instead should be accessed via the chat manager.
|
* used directly, but instead should be accessed via the chat director.
|
||||||
*
|
*
|
||||||
* @see ChatManager
|
* @see ChatDirector
|
||||||
*/
|
*/
|
||||||
public class ChatService
|
public class ChatService implements ChatCodes
|
||||||
{
|
{
|
||||||
/** The module name for the chat services. */
|
|
||||||
public static final String MODULE = "chat";
|
|
||||||
|
|
||||||
/** The message identifier for a speak request message. */
|
|
||||||
public static final String SPEAK_REQUEST = "spkreq";
|
|
||||||
|
|
||||||
/** The message identifier for a speak notification message. */
|
|
||||||
public static final String SPEAK_NOTIFICATION = "spknot";
|
|
||||||
|
|
||||||
/** The message identifier for a tell request. */
|
|
||||||
public static final String TELL_REQUEST = "Tell";
|
|
||||||
|
|
||||||
/** The message identifier for a tell notification. */
|
|
||||||
public static final String TELL_NOTIFICATION = "Tell";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that a tell message be delivered to the user with username
|
* Requests that a tell message be delivered to the user with username
|
||||||
* equal to <code>target</code>.
|
* equal to <code>target</code>.
|
||||||
@@ -40,18 +25,18 @@ public class ChatService
|
|||||||
* @param target the username of the user to which the tell message
|
* @param target the username of the user to which the tell message
|
||||||
* should be delivered.
|
* should be delivered.
|
||||||
* @param message the contents of the message.
|
* @param message the contents of the message.
|
||||||
* @param rsptarget the chat manager reference that will receive the
|
* @param rsptarget the chat director reference that will receive the
|
||||||
* tell response.
|
* tell response.
|
||||||
*
|
*
|
||||||
* @return the invocation request id of the generated tell request.
|
* @return the invocation request id of the generated tell request.
|
||||||
*/
|
*/
|
||||||
public static int tell (Client client, String target, String message,
|
public static int tell (Client client, String target, String message,
|
||||||
ChatManager rsptarget)
|
ChatDirector rsptarget)
|
||||||
{
|
{
|
||||||
InvocationManager invmgr = client.getInvocationManager();
|
InvocationManager invmgr = client.getInvocationManager();
|
||||||
Object[] args = new Object[] { target, message };
|
Object[] args = new Object[] { target, message };
|
||||||
Log.info("Sending tell request [tgt=" + target +
|
Log.info("Sending tell request [tgt=" + target +
|
||||||
", msg=" + message + "].");
|
", msg=" + message + "].");
|
||||||
return invmgr.invoke(MODULE, TELL_REQUEST, args, rsptarget);
|
return invmgr.invoke(MODULE_NAME, TELL_REQUEST, args, rsptarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// $Id: ChatCodes.java,v 1.1 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.cocktail.party.chat;
|
||||||
|
|
||||||
|
import com.threerings.cocktail.cher.client.InvocationCodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains codes used by the chat invocation services.
|
||||||
|
*/
|
||||||
|
public interface ChatCodes extends InvocationCodes
|
||||||
|
{
|
||||||
|
/** The module name for the chat services. */
|
||||||
|
public static final String MODULE_NAME = "chat";
|
||||||
|
|
||||||
|
/** The message identifier for a speak request message. */
|
||||||
|
public static final String SPEAK_REQUEST = "spkreq";
|
||||||
|
|
||||||
|
/** The message identifier for a speak notification message. */
|
||||||
|
public static final String SPEAK_NOTIFICATION = "spknot";
|
||||||
|
|
||||||
|
/** The message identifier for a tell request. */
|
||||||
|
public static final String TELL_REQUEST = "Tell";
|
||||||
|
|
||||||
|
/** The response identifier for a successful tell request. This is
|
||||||
|
* mapped by the invocation services to a call to {@link
|
||||||
|
* ChatDirector#handleTellSucceded}. */
|
||||||
|
public static final String TELL_SUCCEEDED_RESPONSE = "TellSucceeded";
|
||||||
|
|
||||||
|
/** The response identifier for a failed tell request. This is mapped
|
||||||
|
* by the invocation services to a call to {@link
|
||||||
|
* ChatDirector#handleTellFailed}. */
|
||||||
|
public static final String TELL_FAILED_RESPONSE = "TellFailed";
|
||||||
|
|
||||||
|
/** The message identifier for a tell notification. */
|
||||||
|
public static final String TELL_NOTIFICATION = "Tell";
|
||||||
|
|
||||||
|
/** An error code delivered when the user targeted for a tell
|
||||||
|
* notification is not online. */
|
||||||
|
public static final String USER_NOT_ONLINE = "m.user_not_online";
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ChatProvider.java,v 1.3 2001/08/11 00:05:58 mdb Exp $
|
// $Id: ChatProvider.java,v 1.4 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.chat;
|
package com.threerings.cocktail.party.chat;
|
||||||
|
|
||||||
@@ -7,7 +7,12 @@ import com.threerings.cocktail.cher.server.InvocationProvider;
|
|||||||
import com.threerings.cocktail.party.data.BodyObject;
|
import com.threerings.cocktail.party.data.BodyObject;
|
||||||
import com.threerings.cocktail.party.server.PartyServer;
|
import com.threerings.cocktail.party.server.PartyServer;
|
||||||
|
|
||||||
public class ChatProvider extends InvocationProvider
|
/**
|
||||||
|
* The chat provider handles the server side of the chat-related
|
||||||
|
* invocation services.
|
||||||
|
*/
|
||||||
|
public class ChatProvider
|
||||||
|
extends InvocationProvider implements ChatCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Processes a request from a client to deliver a tell message to
|
* Processes a request from a client to deliver a tell message to
|
||||||
@@ -19,15 +24,15 @@ public class ChatProvider extends InvocationProvider
|
|||||||
// look up the target body object
|
// look up the target body object
|
||||||
BodyObject tobj = PartyServer.lookupBody(target);
|
BodyObject tobj = PartyServer.lookupBody(target);
|
||||||
if (tobj == null) {
|
if (tobj == null) {
|
||||||
sendResponse(source, invid, "TellFailed", "m.player_not_online");
|
sendResponse(source, invid, TELL_FAILED_RESPONSE,
|
||||||
|
USER_NOT_ONLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// deliver a tell notification to the target player
|
// deliver a tell notification to the target player
|
||||||
Object[] args = new Object[] { source.username, message };
|
Object[] args = new Object[] { source.username, message };
|
||||||
PartyServer.invmgr.sendNotification(
|
PartyServer.invmgr.sendNotification(
|
||||||
tobj.getOid(), ChatService.MODULE, ChatService.TELL_NOTIFICATION,
|
tobj.getOid(), MODULE_NAME, TELL_NOTIFICATION, args);
|
||||||
args);
|
|
||||||
|
|
||||||
sendResponse(source, invid, "TellSucceeded");
|
sendResponse(source, invid, TELL_SUCCEEDED_RESPONSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
//
|
||||||
|
// $Id: LocationCodes.java,v 1.1 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.cocktail.party.client;
|
||||||
|
|
||||||
|
import com.threerings.cocktail.cher.client.InvocationCodes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains codes used by the location invocation services.
|
||||||
|
*/
|
||||||
|
public interface LocationCodes extends InvocationCodes
|
||||||
|
{
|
||||||
|
/** The module name for the location services. */
|
||||||
|
public static final String MODULE_NAME = "location";
|
||||||
|
|
||||||
|
/** The message identifier for a moveTo request. */
|
||||||
|
public static final String MOVE_TO_REQUEST = "MoveTo";
|
||||||
|
|
||||||
|
/** The response identifier for a successful moveTo request. This is
|
||||||
|
* mapped by the invocation services to a call to {@link
|
||||||
|
* LocationDirector#handleMoveSucceeded}. */
|
||||||
|
public static final String MOVE_SUCCEEDED_RESPONSE = "MoveSucceeded";
|
||||||
|
|
||||||
|
/** The response identifier for a failed moveTo request. This is
|
||||||
|
* mapped by the invocation services to a call to {@link
|
||||||
|
* LocationDirector#handleMoveFailed}. */
|
||||||
|
public static final String MOVE_FAILED_RESPONSE = "MoveFailed";
|
||||||
|
|
||||||
|
/** An error code indicating that a place identified by a particular
|
||||||
|
* place id does not exist. Usually generated by a failed moveTo
|
||||||
|
* request. */
|
||||||
|
public static final String NO_SUCH_PLACE = "m.no_such_place";
|
||||||
|
|
||||||
|
/** An error code sent when a user requests to move to a new place but
|
||||||
|
* they are in the middle of moving somewhere already. */
|
||||||
|
public static final String MOVE_IN_PROGRESS = "m.move_in_progress";
|
||||||
|
|
||||||
|
/** An error code sent when a user requests to move to a place, but
|
||||||
|
* they are already in the requested place. */
|
||||||
|
public static final String ALREADY_THERE = "m.already_there";
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: LocationDirector.java,v 1.8 2001/08/14 06:49:28 mdb Exp $
|
// $Id: LocationDirector.java,v 1.9 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.client;
|
package com.threerings.cocktail.party.client;
|
||||||
|
|
||||||
@@ -15,16 +15,16 @@ import com.threerings.cocktail.party.data.PlaceObject;
|
|||||||
import com.threerings.cocktail.party.util.PartyContext;
|
import com.threerings.cocktail.party.util.PartyContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The location manager provides a means by which entities on the client
|
* The location director provides a means by which entities on the client
|
||||||
* can request to move from place to place and can be notified if other
|
* can request to move from place to place and can be notified if other
|
||||||
* entities have caused the client to move to a new place. It also
|
* entities have caused the client to move to a new place. It also
|
||||||
* provides a mechanism for ratifying a request to move to a new place
|
* provides a mechanism for ratifying a request to move to a new place
|
||||||
* before actually issuing the request.
|
* before actually issuing the request.
|
||||||
*/
|
*/
|
||||||
public class LocationManager
|
public class LocationDirector
|
||||||
implements ClientObserver, Subscriber
|
implements ClientObserver, Subscriber
|
||||||
{
|
{
|
||||||
public LocationManager (PartyContext ctx)
|
public LocationDirector (PartyContext ctx)
|
||||||
{
|
{
|
||||||
// keep this around for later
|
// keep this around for later
|
||||||
_ctx = ctx;
|
_ctx = ctx;
|
||||||
@@ -123,7 +123,7 @@ public class LocationManager
|
|||||||
* This can be called by derived classes that need to coopt the moving
|
* This can be called by derived classes that need to coopt the moving
|
||||||
* process to extend it in some way or other. In such situations, they
|
* process to extend it in some way or other. In such situations, they
|
||||||
* will be responsible for receiving the successful move response and
|
* will be responsible for receiving the successful move response and
|
||||||
* they should let the location manager know that the move has been
|
* they should let the location director know that the move has been
|
||||||
* effected.
|
* effected.
|
||||||
*
|
*
|
||||||
* @param placeId the place oid of our new location.
|
* @param placeId the place oid of our new location.
|
||||||
@@ -172,7 +172,7 @@ public class LocationManager
|
|||||||
|
|
||||||
public void requestFailed (int oid, ObjectAccessException cause)
|
public void requestFailed (int oid, ObjectAccessException cause)
|
||||||
{
|
{
|
||||||
Log.warning("Location manager unable to fetch body " +
|
Log.warning("Location director unable to fetch body " +
|
||||||
"object; all has gone horribly wrong" +
|
"object; all has gone horribly wrong" +
|
||||||
"[cause=" + cause + "].");
|
"[cause=" + cause + "].");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: LocationService.java,v 1.1 2001/07/23 21:14:27 mdb Exp $
|
// $Id: LocationService.java,v 1.2 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.client;
|
package com.threerings.cocktail.party.client;
|
||||||
|
|
||||||
@@ -11,25 +11,22 @@ import com.threerings.cocktail.party.Log;
|
|||||||
* The location services provide a mechanism by which the client can
|
* The location services provide a mechanism by which the client can
|
||||||
* request to move from place to place in the server. These services
|
* request to move from place to place in the server. These services
|
||||||
* should not be used directly, but instead should be accessed via the
|
* should not be used directly, but instead should be accessed via the
|
||||||
* location manager.
|
* location director.
|
||||||
*
|
*
|
||||||
* @see LocationManager
|
* @see LocationDirector
|
||||||
*/
|
*/
|
||||||
public class LocationService
|
public class LocationService implements LocationCodes
|
||||||
{
|
{
|
||||||
/** The module name for the location services. */
|
|
||||||
public static final String MODULE = "location";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests that that this client's body be moved to the specified
|
* Requests that that this client's body be moved to the specified
|
||||||
* location.
|
* location.
|
||||||
*/
|
*/
|
||||||
public static void moveTo (Client client, int placeId,
|
public static void moveTo (Client client, int placeId,
|
||||||
LocationManager rsptarget)
|
LocationDirector rsptarget)
|
||||||
{
|
{
|
||||||
InvocationManager invmgr = client.getInvocationManager();
|
InvocationManager invmgr = client.getInvocationManager();
|
||||||
Object[] args = new Object[] { new Integer(placeId) };
|
Object[] args = new Object[] { new Integer(placeId) };
|
||||||
invmgr.invoke(MODULE, "MoveTo", args, rsptarget);
|
invmgr.invoke(MODULE_NAME, MOVE_TO_REQUEST, args, rsptarget);
|
||||||
Log.info("Sent moveTo request [place=" + placeId + "].");
|
Log.info("Sent moveTo request [place=" + placeId + "].");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: OccupantManager.java,v 1.3 2001/08/21 19:37:08 mdb Exp $
|
// $Id: OccupantManager.java,v 1.4 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.client;
|
package com.threerings.cocktail.party.client;
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ public class OccupantManager
|
|||||||
public OccupantManager (PartyContext ctx)
|
public OccupantManager (PartyContext ctx)
|
||||||
{
|
{
|
||||||
// register ourselves as a location observer
|
// register ourselves as a location observer
|
||||||
ctx.getLocationManager().addLocationObserver(this);
|
ctx.getLocationDirector().addLocationObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,20 +1,21 @@
|
|||||||
//
|
//
|
||||||
// $Id: LocationProvider.java,v 1.7 2001/08/20 20:54:57 mdb Exp $
|
// $Id: LocationProvider.java,v 1.8 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.server;
|
package com.threerings.cocktail.party.server;
|
||||||
|
|
||||||
import com.threerings.cocktail.cher.dobj.DObject;
|
import com.threerings.cocktail.cher.dobj.DObject;
|
||||||
import com.threerings.cocktail.cher.server.InvocationProvider;
|
import com.threerings.cocktail.cher.server.InvocationProvider;
|
||||||
import com.threerings.cocktail.cher.util.Codes;
|
|
||||||
|
|
||||||
import com.threerings.cocktail.party.Log;
|
import com.threerings.cocktail.party.Log;
|
||||||
|
import com.threerings.cocktail.party.client.LocationCodes;
|
||||||
import com.threerings.cocktail.party.data.*;
|
import com.threerings.cocktail.party.data.*;
|
||||||
import com.threerings.cocktail.party.server.PartyServer;
|
import com.threerings.cocktail.party.server.PartyServer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides the server end of the location services.
|
* This class provides the server end of the location services.
|
||||||
*/
|
*/
|
||||||
public class LocationProvider extends InvocationProvider
|
public class LocationProvider
|
||||||
|
extends InvocationProvider implements LocationCodes
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Processes a request from a client to move to a new place.
|
* Processes a request from a client to move to a new place.
|
||||||
@@ -26,10 +27,10 @@ public class LocationProvider extends InvocationProvider
|
|||||||
String rcode = moveTo(source, placeId);
|
String rcode = moveTo(source, placeId);
|
||||||
|
|
||||||
// send the response
|
// send the response
|
||||||
if (rcode.equals(Codes.SUCCESS)) {
|
if (rcode.equals(SUCCESS)) {
|
||||||
sendResponse(source, invid, "MoveSucceeded");
|
sendResponse(source, invid, MOVE_SUCCEEDED_RESPONSE);
|
||||||
} else {
|
} else {
|
||||||
sendResponse(source, invid, "MoveFailed", rcode);
|
sendResponse(source, invid, MOVE_FAILED_RESPONSE, rcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,8 +38,8 @@ public class LocationProvider extends InvocationProvider
|
|||||||
* Moves the specified body from whatever location they currently
|
* Moves the specified body from whatever location they currently
|
||||||
* occupy to the location identified by the supplied place id.
|
* occupy to the location identified by the supplied place id.
|
||||||
*
|
*
|
||||||
* @return the string <code>Codes.SUCCESS</code> if the move was
|
* @return the string <code>SUCCESS</code> if the move was successful
|
||||||
* successful or a reason code for failure if not.
|
* or a reason code for failure if not.
|
||||||
*/
|
*/
|
||||||
public static String moveTo (BodyObject source, int placeId)
|
public static String moveTo (BodyObject source, int placeId)
|
||||||
{
|
{
|
||||||
@@ -49,7 +50,7 @@ public class LocationProvider extends InvocationProvider
|
|||||||
if (pmgr == null) {
|
if (pmgr == null) {
|
||||||
Log.info("Requested to move to non-existent place " +
|
Log.info("Requested to move to non-existent place " +
|
||||||
"[source=" + source + ", place=" + placeId + "].");
|
"[source=" + source + ", place=" + placeId + "].");
|
||||||
return "m.no_such_place";
|
return NO_SUCH_PLACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// acquire a lock on the body object to ensure that rapid fire
|
// acquire a lock on the body object to ensure that rapid fire
|
||||||
@@ -57,13 +58,13 @@ public class LocationProvider extends InvocationProvider
|
|||||||
if (!source.acquireLock("moveToLock")) {
|
if (!source.acquireLock("moveToLock")) {
|
||||||
// if we're still locked, a previous moveTo request hasn't
|
// if we're still locked, a previous moveTo request hasn't
|
||||||
// been fully processed
|
// been fully processed
|
||||||
return "m.move_in_progress";
|
return MOVE_IN_PROGRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure they're not already in the location they're asking to
|
// make sure they're not already in the location they're asking to
|
||||||
// move to
|
// move to
|
||||||
if (source.location == placeId) {
|
if (source.location == placeId) {
|
||||||
return "m.already_there";
|
return ALREADY_THERE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find out if they were previously in some other location
|
// find out if they were previously in some other location
|
||||||
@@ -111,6 +112,6 @@ public class LocationProvider extends InvocationProvider
|
|||||||
// once all these events are processed
|
// once all these events are processed
|
||||||
source.releaseLock("moveToLock");
|
source.releaseLock("moveToLock");
|
||||||
|
|
||||||
return Codes.SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
//
|
//
|
||||||
// $Id: CrowdContext.java,v 1.3 2001/08/20 21:45:37 mdb Exp $
|
// $Id: CrowdContext.java,v 1.4 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.util;
|
package com.threerings.cocktail.party.util;
|
||||||
|
|
||||||
import com.threerings.cocktail.cher.util.CherContext;
|
import com.threerings.cocktail.cher.util.CherContext;
|
||||||
import com.threerings.cocktail.party.client.LocationManager;
|
import com.threerings.cocktail.party.client.LocationDirector;
|
||||||
import com.threerings.cocktail.party.client.OccupantManager;
|
import com.threerings.cocktail.party.client.OccupantManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,9 +14,9 @@ import com.threerings.cocktail.party.client.OccupantManager;
|
|||||||
public interface PartyContext extends CherContext
|
public interface PartyContext extends CherContext
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the location manager.
|
* Returns a reference to the location director.
|
||||||
*/
|
*/
|
||||||
public LocationManager getLocationManager ();
|
public LocationDirector getLocationDirector ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the occupant manager.
|
* Returns a reference to the occupant manager.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Communicator.java,v 1.13 2001/08/07 20:38:58 mdb Exp $
|
// $Id: Communicator.java,v 1.14 2001/10/01 22:14:54 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.cher.client;
|
package com.threerings.cocktail.cher.client;
|
||||||
|
|
||||||
@@ -15,7 +15,6 @@ import com.threerings.cocktail.cher.dobj.DObjectManager;
|
|||||||
import com.threerings.cocktail.cher.io.*;
|
import com.threerings.cocktail.cher.io.*;
|
||||||
import com.threerings.cocktail.cher.io.ObjectStreamException;
|
import com.threerings.cocktail.cher.io.ObjectStreamException;
|
||||||
import com.threerings.cocktail.cher.net.*;
|
import com.threerings.cocktail.cher.net.*;
|
||||||
import com.threerings.cocktail.cher.util.Codes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The client performs all network I/O on separate threads (one for
|
* The client performs all network I/O on separate threads (one for
|
||||||
@@ -340,7 +339,7 @@ public class Communicator
|
|||||||
|
|
||||||
// if the auth request failed, we want to let the communicator
|
// if the auth request failed, we want to let the communicator
|
||||||
// know by throwing a logon exception
|
// know by throwing a logon exception
|
||||||
if (!data.code.equals(Codes.SUCCESS)) {
|
if (!data.code.equals(AuthResponseData.SUCCESS)) {
|
||||||
throw new LogonException(data.code);
|
throw new LogonException(data.code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
//
|
||||||
|
// $Id: InvocationCodes.java,v 1.1 2001/10/01 22:14:54 mdb Exp $
|
||||||
|
|
||||||
|
package com.threerings.cocktail.cher.client;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The invocation codes interface provides codes that are commonly used by
|
||||||
|
* invocation service implementations. It is implemented as an interface
|
||||||
|
* so that were an invocation service to desire to build on two or more
|
||||||
|
* other services, it can provide a codes interface that inherits from all
|
||||||
|
* of the services that it extends.
|
||||||
|
*/
|
||||||
|
public interface InvocationCodes
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Generally used in responses that can either have the value success,
|
||||||
|
* or a string code explaining the reason for failure.
|
||||||
|
*/
|
||||||
|
public static final String SUCCESS = "success";
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: AuthResponseData.java,v 1.6 2001/07/19 07:09:16 mdb Exp $
|
// $Id: AuthResponseData.java,v 1.7 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.cher.net;
|
package com.threerings.cocktail.cher.net;
|
||||||
|
|
||||||
@@ -13,14 +13,18 @@ import com.threerings.cocktail.cher.dobj.DObject;
|
|||||||
*/
|
*/
|
||||||
public class AuthResponseData extends DObject
|
public class AuthResponseData extends DObject
|
||||||
{
|
{
|
||||||
|
/** The constant used to indicate a successful authentication. */
|
||||||
|
public static final String SUCCESS = "success";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Either the string "success" or a reason code for why authentication
|
* Either the {@link #SUCCESS} constant or a reason code indicating
|
||||||
* failed.
|
* why the authentication failed.
|
||||||
*/
|
*/
|
||||||
public String code;
|
public String code;
|
||||||
|
|
||||||
public String toString ()
|
// documentation inherited
|
||||||
|
protected void toString (StringBuffer buf)
|
||||||
{
|
{
|
||||||
return "[code=" + code + "]";
|
buf.append(", code=").append(code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
//
|
//
|
||||||
// $Id: DummyAuthenticator.java,v 1.2 2001/05/30 23:58:31 mdb Exp $
|
// $Id: DummyAuthenticator.java,v 1.3 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.cher.server;
|
package com.threerings.cocktail.cher.server;
|
||||||
|
|
||||||
import com.threerings.cocktail.cher.Log;
|
import com.threerings.cocktail.cher.Log;
|
||||||
import com.threerings.cocktail.cher.net.*;
|
import com.threerings.cocktail.cher.net.*;
|
||||||
import com.threerings.cocktail.cher.server.net.Authenticator;
|
import com.threerings.cocktail.cher.server.net.Authenticator;
|
||||||
import com.threerings.cocktail.cher.util.Codes;
|
|
||||||
|
|
||||||
public class DummyAuthenticator implements Authenticator
|
public class DummyAuthenticator implements Authenticator
|
||||||
{
|
{
|
||||||
@@ -17,7 +16,7 @@ public class DummyAuthenticator implements Authenticator
|
|||||||
{
|
{
|
||||||
Log.info("Accepting request: " + req);
|
Log.info("Accepting request: " + req);
|
||||||
AuthResponseData rdata = new AuthResponseData();
|
AuthResponseData rdata = new AuthResponseData();
|
||||||
rdata.code = Codes.SUCCESS;
|
rdata.code = AuthResponseData.SUCCESS;
|
||||||
return new AuthResponse(rdata);
|
return new AuthResponse(rdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
//
|
|
||||||
// $Id: CherCodes.java,v 1.2 2001/05/30 23:58:31 mdb Exp $
|
|
||||||
|
|
||||||
package com.threerings.cocktail.cher.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The <code>Codes</code> class serves as a repository for miscellaneous
|
|
||||||
* string and integer constants used by componenets of the Cher system.
|
|
||||||
*/
|
|
||||||
public class Codes
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Generally used in responses that can either have the value success,
|
|
||||||
* or a string code explaining the reason for failure.
|
|
||||||
*/
|
|
||||||
public static final String SUCCESS = "success";
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: TestClient.java,v 1.3 2001/08/20 22:10:49 mdb Exp $
|
// $Id: TestClient.java,v 1.4 2001/10/01 22:14:55 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.cocktail.party.client.test;
|
package com.threerings.cocktail.party.client.test;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ public class TestClient
|
|||||||
// create the handles on our various services
|
// create the handles on our various services
|
||||||
_config = new Config();
|
_config = new Config();
|
||||||
_client = new Client(creds, this);
|
_client = new Client(creds, this);
|
||||||
_locmgr = new LocationManager(_ctx);
|
_locdir = new LocationDirector(_ctx);
|
||||||
_occmgr = new OccupantManager(_ctx);
|
_occmgr = new OccupantManager(_ctx);
|
||||||
|
|
||||||
// we want to know about logon/logoff
|
// we want to know about logon/logoff
|
||||||
@@ -58,7 +58,7 @@ public class TestClient
|
|||||||
Log.info("Client did logon [client=" + client + "].");
|
Log.info("Client did logon [client=" + client + "].");
|
||||||
|
|
||||||
// request to move to a place
|
// request to move to a place
|
||||||
_ctx.getLocationManager().moveTo(15);
|
_ctx.getLocationDirector().moveTo(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clientFailedToLogon (Client client, Exception cause)
|
public void clientFailedToLogon (Client client, Exception cause)
|
||||||
@@ -112,9 +112,9 @@ public class TestClient
|
|||||||
return _client.getDObjectManager();
|
return _client.getDObjectManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocationManager getLocationManager ()
|
public LocationDirector getLocationDirector ()
|
||||||
{
|
{
|
||||||
return _locmgr;
|
return _locdir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OccupantManager getOccupantManager ()
|
public OccupantManager getOccupantManager ()
|
||||||
@@ -125,7 +125,7 @@ public class TestClient
|
|||||||
|
|
||||||
protected Config _config;
|
protected Config _config;
|
||||||
protected Client _client;
|
protected Client _client;
|
||||||
protected LocationManager _locmgr;
|
protected LocationDirector _locdir;
|
||||||
protected OccupantManager _occmgr;
|
protected OccupantManager _occmgr;
|
||||||
protected PartyContext _ctx;
|
protected PartyContext _ctx;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user