private class HubConnector.CallHandler extends java.lang.Object implements ResponseHandler
| Modifier and Type | Field and Description |
|---|---|
private java.util.SortedMap |
tagMap_ |
private java.lang.Thread |
timeouter_ |
| Constructor and Description |
|---|
CallHandler()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
ownsTag(java.lang.String tag)
Indicates whether this handler will process the response with a
given message tag.
|
private void |
readyTimeouter()
Ensures that a thread is running to wake up when the next timeout
has (or at least might have) happened.
|
void |
receiveResponse(HubConnection connection,
java.lang.String responderId,
java.lang.String msgTag,
Response response)
Processes a response to an earlier message.
|
void |
registerHandler(java.lang.String tag,
ResultHandler handler,
int timeout)
Stores a ResultHandler object which will take delivery of the
responses tagged with a given tag.
|
private void |
retireIfDone(java.lang.String tag,
HubConnector.CallItem item)
Called when a tag/handler entry might be ready to finish with.
|
void |
setRecipients(java.lang.String tag,
java.lang.String[] recipients)
Set the recipients from which we are expecting responses.
|
private void |
stopTimeouter()
Stops any current timeout watcher operating on behalf of this
handler and tidies up associated resources.
|
void |
unregisterHandler(java.lang.String tag)
Unregister a handler for which no responses are expected.
|
private void |
watchTimeouts()
Runs in a daemon thread to watch out for timeouts that might
have occurred.
|
private final java.util.SortedMap tagMap_
private java.lang.Thread timeouter_
private void readyTimeouter()
private void stopTimeouter()
private void watchTimeouts()
public void registerHandler(java.lang.String tag,
ResultHandler handler,
int timeout)
tag - message tag identifying send/responsehandler - callback objecttimeout - milliseconds before forcing completionpublic void setRecipients(java.lang.String tag,
java.lang.String[] recipients)
tag - message tag identifying send/responserecipients - clients expected to replypublic void unregisterHandler(java.lang.String tag)
tag - message tag identifying send/responsepublic boolean ownsTag(java.lang.String tag)
ResponseHandlerownsTag in interface ResponseHandlertag - tag with which earlier call was labelledmsgTagpublic void receiveResponse(HubConnection connection, java.lang.String responderId, java.lang.String msgTag, Response response)
ResponseHandlermsgTag values which return
true from ResponseHandler.ownsTag(java.lang.String).receiveResponse in interface ResponseHandlerconnection - hub connectionresponderId - client id of client sending responsemsgTag - message tag from previous callresponse - response objectprivate void retireIfDone(java.lang.String tag,
HubConnector.CallItem item)