public interface ServiceTopicHandler
A Service Topic is one that provides request/response capability (see
ServiceTopicData). When a Client subscribes to a Service Topic then a
Topic Load Message will be received by the Client that indicates that it is a
Service Load
Message. In response to
such a Message the Client application should create a handler of this type
using the Client connection
method
and declaring a ServiceTopicListener
to receive all responses
and notifications from the Topic.
The handler simplifies the use of such a Topic and avoids having to format messages to send to the Topic or parse messages received from it.
When such a handler is in use then messages received on the Topic will not be
delivered to the Listener
declared to the
client connection
object.
Modifier and Type | Method and Description |
---|---|
AbstractDiffusionClient |
getConnection()
Returns the client connection.
|
String |
getNextRequestId()
Returns a new unique request identifier that may be used in the
request(String, String, TopicMessage) call. |
Message |
getServiceData()
Returns a message containing any fixed data returned by the service on
subscription.
|
String |
getServiceType()
Returns the service type.
|
void |
request(String requestType,
String requestId,
TopicMessage data)
Sends a request to the Service.
|
String |
request(String requestType,
TopicMessage data)
Sends a request to the Service.
|
AbstractDiffusionClient getConnection()
String getServiceType()
This is the service type as returned by the ServiceTopicData.
Message getServiceData()
The message may contain headers and/or data as set in the ServiceTopicData or may be empty if no data was set.
String request(String requestType, TopicMessage data) throws APIException
If the request succeeds then a response will be returned on
ServiceTopicListener.serviceResponse(ServiceTopicResponse)
and
if it fails or is timed out at the server then an error will be returned
on ServiceTopicListener.serviceError(ServiceTopicError)
.
requestType
- the request type. This must be one of the allowed
types for the service.data
- optional request data. If supplied then the headers and
data from the given Message will be sent with the request.APIException
- if request failedString getNextRequestId()
request(String, String, TopicMessage)
call.void request(String requestType, String requestId, TopicMessage data) throws APIException
If the request succeeds then a response will be returned on
ServiceTopicListener.serviceResponse(ServiceTopicResponse)
and
if it fails or is timed out at the server then an error will be returned
on ServiceTopicListener.serviceError(ServiceTopicError)
.
requestType
- the request type. This must be one of the allowed
types for the service.requestId
- a unique request identifier. This must be unique - the
getNextRequestId()
method may be used to generate a unique
identifier. If the identifier passed is not unique then the results will
be unpredictable.data
- optional request data. If supplied then the headers and
data from the given Message will be sent with the request.APIException
- if request failedCopyright © 2016 Push Technology Ltd. All Rights Reserved.