Package org.astrogrid.samp.web
Class WebCallableClient
- java.lang.Object
-
- org.astrogrid.samp.web.WebCallableClient
-
- All Implemented Interfaces:
CallableClient
class WebCallableClient extends java.lang.Object implements CallableClient
CallableClient implementation used internally by the Web Profile hub.- Since:
- 2 Feb 2011
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description private int
capacity_
static int
DEFAULT_CAPACITY
Default maximum for queued callbacks.private boolean
ended_
private java.util.List
queue_
-
Constructor Summary
Constructors Constructor Description WebCallableClient()
Constructs a callable client with default maximum capacity.WebCallableClient(int capacity)
Constructs a callable client with a given maximum callback capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
endCallbacks()
Informs this client that no further callbacks (receive* methods) will be made on it.private void
enqueue(java.lang.String methodName, java.lang.Object[] params)
Adds a new callback to the queue which can be passed out via thepullCallbacks(int)
method.java.util.List
pullCallbacks(int timeout)
Blocks for up to a given number of seconds or until any callbacks are ready, then returns any ready callbacks.void
receiveCall(java.lang.String senderId, java.lang.String msgId, Message message)
Receives a message for which a response is required.void
receiveNotification(java.lang.String senderId, Message message)
Receives a message for which no response is required.void
receiveResponse(java.lang.String responderId, java.lang.String msgTag, Response response)
Receives a response to a message previously sent by this client.
-
-
-
Field Detail
-
queue_
private final java.util.List queue_
-
capacity_
private final int capacity_
-
ended_
private boolean ended_
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITY
Default maximum for queued callbacks.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
WebCallableClient
public WebCallableClient()
Constructs a callable client with default maximum capacity.
-
WebCallableClient
public WebCallableClient(int capacity)
Constructs a callable client with a given maximum callback capacity.- Parameters:
capacity
- maximum number of queued callbacks
-
-
Method Detail
-
pullCallbacks
public java.util.List pullCallbacks(int timeout) throws SampException
Blocks for up to a given number of seconds or until any callbacks are ready, then returns any ready callbacks.- Parameters:
timeout
- timeout in seconds- Returns:
- list of
Callback
-like Maps - Throws:
SampException
-
receiveNotification
public void receiveNotification(java.lang.String senderId, Message message)
Description copied from interface:CallableClient
Receives a message for which no response is required.- Specified by:
receiveNotification
in interfaceCallableClient
- Parameters:
senderId
- public ID of sending clientmessage
- message
-
receiveCall
public void receiveCall(java.lang.String senderId, java.lang.String msgId, Message message)
Description copied from interface:CallableClient
Receives a message for which a response is required. The implementation must take care to call the hub'sreply
method at some future point.- Specified by:
receiveCall
in interfaceCallableClient
- Parameters:
senderId
- public ID of sending clientmsgId
- message identifier for later use with replymessage
- message
-
receiveResponse
public void receiveResponse(java.lang.String responderId, java.lang.String msgTag, Response response)
Description copied from interface:CallableClient
Receives a response to a message previously sent by this client.- Specified by:
receiveResponse
in interfaceCallableClient
- Parameters:
responderId
- public ID of responding clientmsgTag
- client-defined tag labelling previously-sent messageresponse
- returned response object
-
endCallbacks
public void endCallbacks()
Informs this client that no further callbacks (receive* methods) will be made on it.
-
enqueue
private void enqueue(java.lang.String methodName, java.lang.Object[] params)
Adds a new callback to the queue which can be passed out via thepullCallbacks(int)
method.- Parameters:
methodName
- callback method nameparams
- callback parameter list
-
-