|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.presents.client.ClientDObjectMgr
public class ClientDObjectMgr
The client distributed object manager manages a set of proxy objects which mirror the distributed objects maintained on the server. Requests for modifications, etc. are forwarded to the server and events are dispatched from the server to this client for objects to which this client is subscribed.
| Nested Class Summary | |
|---|---|
protected static class |
ClientDObjectMgr.FlushRecord
Used to manage pending object flushes. |
protected static class |
ClientDObjectMgr.ObjectAction<T extends DObject>
The object action is used to queue up a subscribe or unsubscribe request. |
protected static class |
ClientDObjectMgr.PendingRequest<T extends DObject>
Represents a pending subscription request. |
| Field Summary | |
|---|---|
protected Queue<Object> |
_actions
Our primary dispatch queue. |
protected Client |
_client
A reference to our client instance. |
protected Communicator |
_comm
A reference to the communicator that sends and receives messages for this client. |
protected HashIntMap<DObject> |
_dead
Objects that have been marked for death. |
protected HashMap<Class<?>,Long> |
_delays
A mapping from distributed object class to flush delay. |
protected Interval |
_flusher
Periodically calls flushObject(com.threerings.presents.dobj.DObject). |
protected HashIntMap<ClientDObjectMgr.FlushRecord> |
_flushes
A set of objects waiting to be flushed. |
protected HashIntMap<DObject> |
_ocache
All of the distributed objects that are active on this client. |
protected HashIntMap<ClientDObjectMgr.PendingRequest<?>> |
_penders
Pending object subscriptions. |
protected static int |
DUMP_OTABLE_KEYCODE
The key code for our dump table debug hook (o). |
protected static int |
DUMP_OTABLE_MODMASK
The modifiers for our dump table debug hook (Alt+Shift). |
protected static long |
FLUSH_INTERVAL
Flush expired objects every 30 seconds. |
| Constructor Summary | |
|---|---|
ClientDObjectMgr(Communicator comm,
Client client)
Constructs a client distributed object manager. |
|
| Method Summary | ||
|---|---|---|
void |
cleanup()
Called when the client is cleaned up due to having disconnected from the server. |
|
protected void |
dispatchAction(Object obj)
|
|
protected void |
dispatchEvent(DEvent event)
Called when a new event arrives from the server that should be dispatched to subscribers here on the client. |
|
protected void |
dispatchEvent(int remoteOid,
DObject target,
DEvent event)
Dispatches an event on an already resolved target object. |
|
protected
|
doSubscribe(ClientDObjectMgr.ObjectAction<T> action)
This is guaranteed to be invoked via the invoker and can safely do main thread type things like call back to the subscriber. |
|
protected void |
doUnsubscribe(int oid,
Subscriber<?> target)
This is guaranteed to be invoked via the invoker and can safely do main thread type things like call back to the subscriber. |
|
protected void |
flushObject(DObject obj)
Flushes a distributed object subscription, issuing an unsubscribe request to the server. |
|
protected void |
flushObjects()
Called periodically to flush any objects that have been lingering due to a previously enacted flush delay. |
|
boolean |
isManager(DObject object)
Returns true if this distributed object manager is the authoritative manager for the specified distributed object, or false if we are only providing a proxy to the object. |
|
protected void |
notifyFailure(int oid,
String message)
Notifies the subscribers that had requested this object (for subscription) that it is not available. |
|
void |
postEvent(DEvent event)
Posts a distributed object event into the system. |
|
void |
processMessage(Message msg)
Called by the communicator when a message arrives from the network layer. |
|
protected
|
queueAction(int oid,
Subscriber<T> target,
boolean subscribe)
|
|
void |
registerFlushDelay(Class<?> objclass,
long delay)
Registers an object flush delay. |
|
protected
|
registerObjectAndNotify(ObjectResponse<T> orsp)
Registers this object in our proxy cache and notifies the subscribers that were waiting for subscription to this object. |
|
void |
removedLastSubscriber(DObject obj,
boolean deathWish)
When a distributed object removes its last subscriber, it will call this function to let the object manager know. |
|
void |
run()
Invoked on the main client thread to process any newly arrived messages that we have waiting in our queue. |
|
|
subscribeToObject(int oid,
Subscriber<T> target)
Requests that the specified subscriber be subscribed to the object identified by the supplied object id. |
|
|
unsubscribeFromObject(int oid,
Subscriber<T> target)
Requests that the specified subscriber be unsubscribed from the object identified by the supplied object id. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected Communicator _comm
protected Client _client
protected Interval _flusher
flushObject(com.threerings.presents.dobj.DObject).
protected Queue<Object> _actions
protected HashIntMap<DObject> _ocache
protected HashIntMap<DObject> _dead
protected HashIntMap<ClientDObjectMgr.PendingRequest<?>> _penders
protected HashMap<Class<?>,Long> _delays
protected HashIntMap<ClientDObjectMgr.FlushRecord> _flushes
protected static int DUMP_OTABLE_MODMASK
protected static int DUMP_OTABLE_KEYCODE
protected static final long FLUSH_INTERVAL
| Constructor Detail |
|---|
public ClientDObjectMgr(Communicator comm,
Client client)
comm - a communicator instance by which it can communicate with the server.client - a reference to the client that is managing this whole communications and event
dispatch business.| Method Detail |
|---|
public boolean isManager(DObject object)
DObjectManager
isManager in interface DObjectManager
public <T extends DObject> void subscribeToObject(int oid,
Subscriber<T> target)
DObjectManager
subscribeToObject in interface DObjectManageroid - The object id of the distributed object to which subscription is desired.target - The subscriber to be subscribed.Subscriber.objectAvailable(T),
Subscriber.requestFailed(int, com.threerings.presents.dobj.ObjectAccessException)
public <T extends DObject> void unsubscribeFromObject(int oid,
Subscriber<T> target)
DObjectManager
unsubscribeFromObject in interface DObjectManageroid - The object id of the distributed object from which unsubscription is desired.target - The subscriber to be unsubscribed.public void postEvent(DEvent event)
DObjectManagerAttributeChangedEvent can be constructed and posted directly. This
is true for all event types and is useful for situations where one doesn't have access to
the object in question, but needs to affect some event.
This event will be forwarded to the ultimate manager of the object (on the client, this means it will be forwarded to the server) where it will be checked for validity and then applied to the object and dispatched to all its subscribers.
postEvent in interface DObjectManagerevent - The event to be dispatched.
public void removedLastSubscriber(DObject obj,
boolean deathWish)
DObjectManager
removedLastSubscriber in interface DObjectManager
public void registerFlushDelay(Class<?> objclass,
long delay)
Client.registerFlushDelay(java.lang.Class>, long)public void processMessage(Message msg)
public void run()
run in interface Runnableprotected void dispatchAction(Object obj)
public void cleanup()
protected <T extends DObject> void queueAction(int oid,
Subscriber<T> target,
boolean subscribe)
protected void dispatchEvent(DEvent event)
protected void dispatchEvent(int remoteOid,
DObject target,
DEvent event)
remoteOid - is specified explicitly because we will have already translated the event's
target oid into our local object managers oid space if we're acting on behalf of the peer
manager.protected <T extends DObject> void registerObjectAndNotify(ObjectResponse<T> orsp)
protected void notifyFailure(int oid,
String message)
protected <T extends DObject> void doSubscribe(ClientDObjectMgr.ObjectAction<T> action)
protected void doUnsubscribe(int oid,
Subscriber<?> target)
protected void flushObject(DObject obj)
protected void flushObjects()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||