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 intcapacity_static intDEFAULT_CAPACITYDefault maximum for queued callbacks.private booleanended_private java.util.Listqueue_
-
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 voidendCallbacks()Informs this client that no further callbacks (receive* methods) will be made on it.private voidenqueue(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.ListpullCallbacks(int timeout)Blocks for up to a given number of seconds or until any callbacks are ready, then returns any ready callbacks.voidreceiveCall(java.lang.String senderId, java.lang.String msgId, Message message)Receives a message for which a response is required.voidreceiveNotification(java.lang.String senderId, Message message)Receives a message for which no response is required.voidreceiveResponse(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 SampExceptionBlocks 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:CallableClientReceives a message for which no response is required.- Specified by:
receiveNotificationin 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:CallableClientReceives a message for which a response is required. The implementation must take care to call the hub'sreplymethod at some future point.- Specified by:
receiveCallin 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:CallableClientReceives a response to a message previously sent by this client.- Specified by:
receiveResponsein 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
-
-