Packagecom.pushtechnology.diffusion
Classpublic class ServiceTopicHandler
InheritanceServiceTopicHandler Inheritance Object

Since : 4.1

A Service Topic Handler.

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 Message#isServiceLoad() Service Load Message. In response to such a Message the Client application should create a handler of this type using the Client connection DiffusionClientImpl#createServiceTopicHandler(Message, ServiceTopicListener) 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 DiffusionConnectionListener Listener declared to the DiffusionClientImpl client connection object.



Public Methods
 MethodDefined By
  
ServiceTopicHandler
  
Returns the client connection.
ServiceTopicHandler
  
Returns a message containing any fixed data returned by the service on subscription.
ServiceTopicHandler
  
Returns the service type.
ServiceTopicHandler
  
getTopic():String
Returns the topic name.
ServiceTopicHandler
  
request(requestType:String, data:TopicMessage, requestId:String = null):String
Sends a request to the Service.
ServiceTopicHandler
Constructor Detail
ServiceTopicHandler()Constructor
public function ServiceTopicHandler(diffusionClient:DiffusionClient, message:TopicMessage, listener:ServiceTopicListener)



Parameters
diffusionClient:DiffusionClient
 
message:TopicMessage
 
listener:ServiceTopicListener
Method Detail
getConnection()method
public function getConnection():DiffusionClient

Returns the client connection.

Returns
DiffusionClient — the client connection.
getServiceData()method 
public function getServiceData():TopicMessage

Returns a message containing any fixed data returned by the service on subscription.

The message may contain headers and/or data as set in the ServiceTopicData or may be empty if no data was set.

Returns
TopicMessage — service data message
getServiceType()method 
public function getServiceType():String

Returns the service type.

This is the service type as returned by the ServiceTopicData.

Returns
String — service type.
getTopic()method 
public function getTopic():String

Returns the topic name.

Returns
String — the topic name.
request()method 
public function request(requestType:String, data:TopicMessage, requestId:String = null):String

Sends a request to the Service.

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).

Parameters

requestType:String — the request type. This must be one of the allowed types for the service.
 
data:TopicMessage — optional request data. If supplied then the headers and data from the given Message will be sent with the request.
 
requestId:String (default = null) — a unique request identifier. This must be unique. If the identifier passed is not unique then the results will be unpredictable. This value will default to null. If the value is null then the identifier will be generated.

Returns
String — unique request identifier

Throws
com.pushtechnology.diffusion.errors:UnsupportedServerMethodError — UnsupportedServerMethodError if sendTopicMessage would throw the same