|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.presents.client.InvocationDirector
public class InvocationDirector
Handles the client side management of the invocation services.
| Field Summary | |
|---|---|
protected Client |
_client
The client for whom we're working. |
protected ClientObject |
_clobj
Our client object; invocation responses and notifications are received on this object. |
protected long |
_lastFlushTime
The last time we flushed our listeners. |
protected HashIntMap<InvocationMarshaller.ListenerMarshaller> |
_listeners
Used to keep track of invocation service listeners which will receive responses from invocation service requests. |
protected DObjectManager |
_omgr
The distributed object manager with which we interact. |
protected short |
_receiverId
Used to generate monotonically increasing receiver ids. |
protected HashIntMap<InvocationDecoder> |
_receivers
Used to keep track of invocation notification receivers. |
protected ArrayList<InvocationDecoder> |
_reclist
All registered receivers are maintained in a list so that we can assign receiver ids to them when we go online. |
protected short |
_requestId
Used to generate monotonically increasing request ids. |
protected static long |
LISTENER_FLUSH_INTERVAL
The minimum interval between listener flush attempts. |
protected static long |
LISTENER_MAX_AGE
Listener mappings older than 90 seconds are reaped. |
| Constructor Summary | |
|---|---|
InvocationDirector()
|
|
| Method Summary | |
|---|---|
protected void |
assignReceiverId(InvocationDecoder decoder)
Assigns a receiver id to this decoder and publishes it in the ClientObject.receivers
field. |
protected void |
assignReceiverIds()
Called when we log on; generates mappings for all receivers registered prior to logon. |
void |
cleanup()
Clears out our session information. |
void |
eventReceived(DEvent event)
Process notification and response events arriving on user object. |
protected void |
flushListeners(long now)
Flushes listener mappings that are older than LISTENER_MAX_AGE milliseconds. |
protected void |
handleClientObjectChanged(int newCloid)
Called when the server has informed us that our previous client object is going the way of the Dodo because we're changing screen names. |
protected void |
handleInvocationNotification(int receiverId,
int methodId,
Object[] args)
Dispatches an invocation notification. |
protected void |
handleInvocationResponse(int reqId,
int methodId,
Object[] args)
Dispatches an invocation response. |
void |
init(DObjectManager omgr,
int cloid,
Client client)
Initializes the invocation director. |
protected short |
nextReceiverId()
Used to generate monotonically increasing invocation receiver ids. |
protected short |
nextRequestId()
Used to generate monotonically increasing invocation request ids. |
void |
registerReceiver(InvocationDecoder decoder)
Registers an invocation notification receiver by way of its notification event decoder. |
void |
sendRequest(int invOid,
int invCode,
int methodId,
Object[] args)
Requests that the specified invocation request be packaged up and sent to the supplied invocation oid. |
void |
sendRequest(int invOid,
int invCode,
int methodId,
Object[] args,
Transport transport)
Requests that the specified invocation request be packaged up and sent to the supplied invocation oid. |
void |
unregisterReceiver(String receiverCode)
Removes a receiver registration. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected DObjectManager _omgr
protected Client _client
protected ClientObject _clobj
protected short _requestId
protected short _receiverId
protected HashIntMap<InvocationMarshaller.ListenerMarshaller> _listeners
protected HashIntMap<InvocationDecoder> _receivers
protected ArrayList<InvocationDecoder> _reclist
protected long _lastFlushTime
protected static final long LISTENER_FLUSH_INTERVAL
protected static final long LISTENER_MAX_AGE
| Constructor Detail |
|---|
public InvocationDirector()
| Method Detail |
|---|
public void init(DObjectManager omgr,
int cloid,
Client client)
omgr - the distributed object manager via which the invocation manager will send and
receive events.cloid - the oid of the object on which invocation notifications as well as invocation
responses will be received.client - a reference to the client for whom we're doing our business.public void cleanup()
public void registerReceiver(InvocationDecoder decoder)
public void unregisterReceiver(String receiverCode)
protected void assignReceiverIds()
protected void assignReceiverId(InvocationDecoder decoder)
ClientObject.receivers
field.
public void sendRequest(int invOid,
int invCode,
int methodId,
Object[] args)
public void sendRequest(int invOid,
int invCode,
int methodId,
Object[] args,
Transport transport)
public void eventReceived(DEvent event)
eventReceived in interface EventListenerevent - The event that was dispatched on the object.
protected void handleInvocationResponse(int reqId,
int methodId,
Object[] args)
protected void handleInvocationNotification(int receiverId,
int methodId,
Object[] args)
protected void handleClientObjectChanged(int newCloid)
protected void flushListeners(long now)
LISTENER_MAX_AGE milliseconds. An
alternative to flushing listeners that did not explicitly receive a response within our
expiry time period is to have the server's proxy listener send a message to the client when
it is finalized. We then know that no server entity will subsequently use that proxy
listener to send a response to the client. This involves more network traffic and complexity
than seems necessary and if a user of the system does respond after their listener has been
flushed, an informative warning will be logged. (Famous last words.)
protected short nextRequestId()
protected short nextReceiverId()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||