|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.presents.client.BasicDirector
com.threerings.crowd.client.LocationDirector
public class LocationDirector
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 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 before actually issuing the request.
| Nested Class Summary | |
|---|---|
static interface |
LocationDirector.FailureHandler
Used to recover from a moveTo request that was accepted but resulted in a failed attempt to fetch the place object to which we were moving. |
| Nested classes/interfaces inherited from interface com.threerings.presents.client.InvocationReceiver |
|---|
InvocationReceiver.Registration |
| Field Summary | |
|---|---|
protected PlaceController |
_controller
The place controller in effect for our current place. |
protected CrowdContext |
_ctx
The context through which we access needed services. |
protected com.samskivert.util.ObserverList.ObserverOp<LocationObserver> |
_didChangeOp
The operation used to inform observers that the location changed. |
protected LocationDirector.FailureHandler |
_failureHandler
The entity that deals when we fail to subscribe to a place object. |
protected long |
_lastRequestTime
The last time we requested a move to. |
protected LocationService |
_lservice
Provides access to location services. |
protected com.samskivert.util.ResultListener<PlaceConfig> |
_moveListener
A listener that wants to know if we succeeded or how we failed to move. |
protected com.samskivert.util.ObserverList<LocationObserver> |
_observers
Our location observer list. |
protected int |
_pendingPlaceId
The oid of the place for which we have an outstanding moveTo request, or -1 if we have no outstanding request. |
protected int |
_placeId
The oid of the place we currently occupy. |
protected PlaceObject |
_plobj
The place object that we currently occupy. |
protected int |
_previousPlaceId
The oid of the place we previously occupied. |
protected SafeSubscriber<PlaceObject> |
_subber
Used to subscribe to our place object. |
protected static long |
STALE_REQUEST_DURATION
We require that a moveTo request be outstanding for one minute before it is declared to be stale. |
| Fields inherited from class com.threerings.presents.client.BasicDirector |
|---|
_availableInStandalone |
| Fields inherited from interface com.threerings.crowd.data.LocationCodes |
|---|
ALREADY_THERE, MOVE_IN_PROGRESS, NO_SUCH_PLACE |
| Fields inherited from interface com.threerings.presents.data.InvocationCodes |
|---|
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR |
| Constructor Summary | |
|---|---|
LocationDirector(CrowdContext ctx)
Constructs a location director which will configure itself for operation using the supplied context. |
|
| Method Summary | |
|---|---|
void |
addLocationObserver(LocationObserver observer)
Adds a location observer to the list. |
boolean |
checkRepeatMove()
Called to test and set a time stamp that we use to determine if a pending moveTo request is stale. |
void |
clientDidLogoff(Client client)
Called after the client has been logged off of the server and has disconnected. |
void |
clientDidLogon(Client client)
Called after the client successfully connected to and authenticated with the server. |
protected PlaceController |
createController(PlaceConfig config)
Called to create our place controller using the supplied place configuration. |
void |
didLeavePlace()
Called when we're leaving our current location. |
void |
didMoveTo(int placeId,
PlaceConfig config)
This can be called by cooperating directors that need to coopt the moving process to extend it in some way or other. |
void |
failedToMoveTo(int placeId,
String reason)
This can be called by cooperating directors that need to coopt the moving process to extend it in some way or other. |
protected void |
fetchServices(Client client)
Derived directors can override this method and obtain any services they'll need during their operation via calls to Client.getService(java.lang.Class. |
void |
forcedMove(int placeId)
Used to communicate a required move notification to the client. |
PlaceObject |
getPlaceObject()
Returns the place object for the location we currently occupy or null if we're not currently occupying any location. |
protected void |
gotBodyObject(BodyObject clobj)
|
protected void |
gotPlaceObject(PlaceObject object)
|
protected void |
handleFailure(int placeId,
String reason)
|
boolean |
leavePlace()
Issues a request to leave our current location. |
protected void |
mayLeavePlace()
Called to inform our controller that we may be leaving the current place. |
boolean |
mayMoveTo(int placeId,
com.samskivert.util.ResultListener<PlaceConfig> rl)
This can be called by cooperating directors that need to coopt the moving process to extend it in some way or other. |
boolean |
moveBack()
Requests to move to the room that we last occupied, if such a room exists. |
boolean |
movePending()
Returns true if there is a pending move request. |
boolean |
moveTo(int placeId)
Requests that this client be moved to the specified place. |
protected void |
registerServices(Client client)
If a director makes use of bootstrap invocation services which are part of a bootstrap service group, it should register interest in that group here with a call to Client.addServiceGroup(java.lang.String). |
void |
removeLocationObserver(LocationObserver observer)
Removes a location observer from the list. |
void |
setFailureHandler(LocationDirector.FailureHandler handler)
Sets the failure handler which will recover from place object fetching failures. |
| Methods inherited from class com.threerings.presents.client.BasicDirector |
|---|
assertAvailable, clientObjectDidChange, clientObjectUpdated, clientWillLogon, isAvailable, isAvailableInStandalone, setAvailableInStandalone |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected CrowdContext _ctx
protected LocationService _lservice
protected com.samskivert.util.ObserverList<LocationObserver> _observers
protected SafeSubscriber<PlaceObject> _subber
protected int _placeId
protected PlaceObject _plobj
protected PlaceController _controller
protected int _pendingPlaceId
protected int _previousPlaceId
protected long _lastRequestTime
protected LocationDirector.FailureHandler _failureHandler
protected com.samskivert.util.ResultListener<PlaceConfig> _moveListener
protected com.samskivert.util.ObserverList.ObserverOp<LocationObserver> _didChangeOp
protected static final long STALE_REQUEST_DURATION
| Constructor Detail |
|---|
public LocationDirector(CrowdContext ctx)
| Method Detail |
|---|
public void addLocationObserver(LocationObserver observer)
public void removeLocationObserver(LocationObserver observer)
public PlaceObject getPlaceObject()
public boolean movePending()
public boolean moveTo(int placeId)
public boolean moveBack()
public boolean leavePlace()
public boolean mayMoveTo(int placeId,
com.samskivert.util.ResultListener<PlaceConfig> rl)
placeId - the place oid of our tentative new location.
protected void mayLeavePlace()
public void didMoveTo(int placeId,
PlaceConfig config)
placeId - the place oid of our new location.config - the configuration information for the new place.public void didLeavePlace()
public void failedToMoveTo(int placeId,
String reason)
placeId - the place oid to which we failed to move.reason - the reason code given for failure.public boolean checkRepeatMove()
public void clientDidLogon(Client client)
SessionObserver
clientDidLogon in interface SessionObserverclientDidLogon in class BasicDirectorpublic void clientDidLogoff(Client client)
SessionObserver
clientDidLogoff in interface SessionObserverclientDidLogoff in class BasicDirectorprotected void registerServices(Client client)
BasicDirectorClient.addServiceGroup(java.lang.String).
registerServices in class BasicDirectorprotected void fetchServices(Client client)
BasicDirectorClient.getService(java.lang.Class) . If the director is available, it will
automatically be called when the client logs on or when the director is constructed if it is
constructed after the client is already logged on.
fetchServices in class BasicDirectorprotected void gotPlaceObject(PlaceObject object)
protected void gotBodyObject(BodyObject clobj)
public void forcedMove(int placeId)
LocationReceiverLocationService.moveTo(com.threerings.presents.client.Client, int, com.threerings.crowd.client.LocationService.MoveListener) request to move to the new location.
forcedMove in interface LocationReceiverpublic void setFailureHandler(LocationDirector.FailureHandler handler)
protected void handleFailure(int placeId,
String reason)
protected PlaceController createController(PlaceConfig config)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||