public abstract class AbstractMessageHandler extends Object implements MessageHandler
processCall(org.astrogrid.samp.client.HubConnection, java.lang.String, org.astrogrid.samp.Message) method.| Modifier | Constructor and Description | 
|---|---|
| protected  | AbstractMessageHandler(Map subscriptions)Constructor using a given subscriptions map. | 
| protected  | AbstractMessageHandler(String mtype)Constructor using a single subscribed MType. | 
| protected  | AbstractMessageHandler(String[] mtypes)Constructor using a given list of subscribed MTypes. | 
| Modifier and Type | Method and Description | 
|---|---|
| protected Response | createResponse(Map processOutput)Invoked by  receiveCallto create a success 
 response from the result of callingprocessCall. | 
| Map | getSubscriptions()Returns a Subscriptions map corresponding to the messages 
 handled by this object. | 
| abstract Map | processCall(HubConnection connection,
           String senderId,
           Message message)Implements message processing. | 
| void | receiveCall(HubConnection connection,
           String senderId,
           String msgId,
           Message message)Calls  processCall(org.astrogrid.samp.client.HubConnection, java.lang.String, org.astrogrid.samp.Message), generates a response from the result
 usingcreateResponse(java.util.Map), and sends the resulting response
 as a reply to the hub. | 
| void | receiveNotification(HubConnection connection,
                   String senderId,
                   Message message)Calls  processCall(org.astrogrid.samp.client.HubConnection, java.lang.String, org.astrogrid.samp.Message)and discards the result. | 
| void | setSubscriptions(Map subscriptions)Sets the subscriptions map. | 
protected AbstractMessageHandler(Map subscriptions)
subscriptions - Subscriptions-like map
                        defining which MTypes this handler can processprotected AbstractMessageHandler(String[] mtypes)
mtypes - list of MTypes which this handler can processprotected AbstractMessageHandler(String mtype)
mtype - single MType which this handler can processpublic abstract Map processCall(HubConnection connection, String senderId, Message message) throws Exception
samp.result part 
 of the call response, that is the MType-specific return value
 name->value map.
 As a special case, returning null is equivalent to returning an empty 
 map.
 However, if createResponse(java.util.Map) is overridden, the return value
 semantics may be different.connection - hub connectionsenderId - public ID of sender clientmessage - message with MType this handler is subscribed tocreateResponse implementationExceptionprotected Response createResponse(Map processOutput)
receiveCall to create a success 
 response from the result of calling processCall.
 The default implementation calls 
 Response.createSuccessResponse(java.util.Map)(processOutput),
 first transforming a null value to an empty map for convenience.
 However, it may be overridden for more flexibility (for instance
 in order to return non-OK responses).
processOutput - a Map returned by processCallpublic void setSubscriptions(Map subscriptions)
subscriptions - Subscriptions-like map
                        defining which MTypes this handler can processpublic Map getSubscriptions()
MessageHandlergetSubscriptions in interface MessageHandlerSubscriptions-like mappublic void receiveNotification(HubConnection connection, String senderId, Message message)
processCall(org.astrogrid.samp.client.HubConnection, java.lang.String, org.astrogrid.samp.Message) and discards the result.receiveNotification in interface MessageHandlerconnection - hub connectionsenderId - public ID of client which sent the messagemessage - messagepublic void receiveCall(HubConnection connection, String senderId, String msgId, Message message) throws SampException
processCall(org.astrogrid.samp.client.HubConnection, java.lang.String, org.astrogrid.samp.Message), generates a response from the result
 using createResponse(java.util.Map), and sends the resulting response
 as a reply to the hub.  In case of an exception, a suitable error 
 response is sent instead.receiveCall in interface MessageHandlerconnection - hub connectionsenderId - public ID of client which sent the messagemsgId - message IDmessage - messageSampExceptionCopyright © 2008–2024. All rights reserved.