Package | com.pushtechnology.diffusion |
Class | public class DiffusionClient |
Inheritance | DiffusionClient ![]() |
If load balance is not set on the connection details, then the server details will be processed in order. If load balance is set, then the server order will be randomised.
Method | Defined By | ||
---|---|---|---|
DiffusionClient | |||
acknowledge(message:TopicMessage):void
Send a message acknowledgement back to the server, if Auto Ack is not
swicthed on. | DiffusionClient | ||
addServiceAndPagedListener(pattern:String, functionPointer:Function, thisContext:Object = null):int
Add the Listener to the start of the list and not to the end as addTopicListener does, so this Listener have more priority. | DiffusionClient | ||
addTimedTopicListener(pattern:String, functionPointer:Function, time:Number, force:Boolean = false, thisContext:Object = null):int | DiffusionClient | ||
addTopicListener(pattern:String, functionPointer:Function, thisContext:Object = null):int | DiffusionClient | ||
close():void
Close the connection to Diffusion
| DiffusionClient | ||
connect(connectionDetails:ConnectionDetails):void
Connect to the Diffusion server, using the supplied connection details
| DiffusionClient | ||
Creates a handler object for a 'paged' Topic. | DiffusionClient | ||
Creates a handler object for a 'Service' Topic. | DiffusionClient | ||
createTopicNotifyTopicHandler(message:TopicMessage, listener:TopicNotifyListener):TopicNotifyTopicHandler
Creates a handler object for a 'TopicNotify' topic. | DiffusionClient | ||
enableLivenessMonitor(enable:Boolean):void
Enable or disable the connection liveness monitor. | DiffusionClient | ||
fetch(topic:String, correlationID:String = null):void
Fetch the ITL for the topic. | DiffusionClient | ||
getClientID():String
Get the ID of the connected client
| DiffusionClient | ||
getClientProtocolVersion():int
This returns the client protocol
| DiffusionClient | ||
getLastInteraction():Number
Returns the time (milliseconds since the epoch) of the
last interaction (send or recieve) with the server. | DiffusionClient | ||
getServerProtocolVersion():int
This returns the protocol version of the server
| DiffusionClient | ||
getTopicListeners():Array
Gets an array of all topic listeners. | DiffusionClient | ||
isConnected():Boolean
Returns true if the client is connected
| DiffusionClient | ||
onMessage(event:DiffusionMessageEvent):void | DiffusionClient | ||
ping(timeStamp:String = null, queueSize:String = 0):void
Send a ping request to Diffusion, this in turn will respond with a PingMessage
| DiffusionClient | ||
reconnect():void
Reconnect to Diffusion if possible. | DiffusionClient | ||
removeAllTopicListeners():void
Removes all of the topic listeners
| DiffusionClient | ||
removeTopicListener(handle:int):void
Remove the topic listener, with the handle returned from addTopicListener
| DiffusionClient | ||
reportVersionInformation():void | DiffusionClient | ||
send(topic:String, message:String):void
Send a message to a topic
| DiffusionClient | ||
sendCredentials(credentials:DiffusionClientCredentials):void
Send the credentials to the Diffusion Server. | DiffusionClient | ||
sendTopicMessage(topicMessage:TopicMessage):void
Send a topic message to the server. | DiffusionClient | ||
setAutoAck(value:Boolean):void
This method sets if you would like the API to automatically send message acknowledgments back to the server,
or if the implementation is going to respond to the Ack's via the acknowledge funciton. | DiffusionClient | ||
setConnectionTypes(socketConnectionType:int, pollingConnectionType:String, cometConnectionType:String):void | DiffusionClient | ||
subscribe(topic:String):void | DiffusionClient | ||
unsubscribe(topic:String):void | DiffusionClient |
Constant | Defined By | ||
---|---|---|---|
RELEASE_VERSION : String = 5.9.4_01 [static]
The release version of Diffusion API. | DiffusionClient |
DiffusionClient | () | Constructor |
public function DiffusionClient()
// Get a new Diffusion Client var theClient:DiffusionClient = new DiffusionClient(); // Set up the Connection Details var connectionDetails:ConnectionDetails = new ConnectionDetails("dpt://demo.pushtechnology.com:8080", "MyTopic"); // Set the timeout, as this is set on the connection details, it will be used as the default for // all server details connectionDetails.setTimeout(2000); // Fail back to http, if can not connect to the socket // There are two types of http connection a long poll type connection (http) and a comet type connection (httpc) // In this example, it is using the long poll type connection connectionDetails.addServerDetails(new ServerDetails("http://demo.pushtechnology.com:80")); // It is also possible to add client credentials at this time if required. connectionDetails.setCredentials( new DiffusionClientCredentials("admin","passwd")); // Cascade the connections connectionDetails.setCascade(true); // Add the listeners theClient.addEventListener(DiffusionConnectionEvent.CONNECTION, onConnection); theClient.addEventListener(DiffusionMessageEvent.MESSAGE, onMessages); theClient.addEventListener(DiffusionTraceEvent.TRACE, onTrace); theClient.addEventListener(DiffusionExceptionEvent.EXCEPTION, onException); theClient.addEventListener(DiffusionPingEvent.PING, onPing); theClient.addEventListener(MessageNotAcknowledgedEvent.MESSAGE_NOT_ACKNOWLEDGED, onNotAcked); theClient.addEventListener(TopicStatusEvent.TOPIC_STATUS, onTopicStatus); // If failover / load balance events required theClient.addEventListener(ConnectionDetailsEvent.CONNECTION_DETAILS, onPreConnection); // OK, go.. theClient.connect(connectionDetails);
acknowledge | () | method |
public function acknowledge(message:TopicMessage):void
Send a message acknowledgement back to the server, if Auto Ack is not swicthed on.
Parameters
message:TopicMessage |
addServiceAndPagedListener | () | method |
public function addServiceAndPagedListener(pattern:String, functionPointer:Function, thisContext:Object = null):int
Add the Listener to the start of the list and not to the end as addTopicListener does, so this Listener have more priority.
Parameters
pattern:String — The regex is a String representation of a matches regex pattern on the topic name. For an exact match, use ^topicname$
| |
functionPointer:Function — This is the function to all with a TopicMessage if the pattern matches, | |
thisContext:Object (default = null ) — When the function is called above, it will retain the this context of what was passed to this method
|
int — true if the message is 'consumed' and should not be relayed to subsequent TopicListeners, nor the default listener.
|
addTimedTopicListener | () | method |
public function addTimedTopicListener(pattern:String, functionPointer:Function, time:Number, force:Boolean = false, thisContext:Object = null):int
Parameters
pattern:String — The regex is a String representation of a matches regex pattern on the topic name. For an exact match, use ^topicname$
| |
functionPointer:Function — This is the function to all with a TopicMessage if the pattern matches, NOTE: It can NOT return if the message was 'consumed' as TopicListener does.
| |
time:Number — Call the | |
force:Boolean (default = false ) — Force to call the function even if any message has been received
| |
thisContext:Object (default = null ) — When the function is called above, it will retain the this context of what was passed to this method
|
int |
addTopicListener | () | method |
public function addTopicListener(pattern:String, functionPointer:Function, thisContext:Object = null):int
Parameters
pattern:String — The regex is a String representation of a matches regex pattern on the topic name. For an exact match, use ^topicname$
| |
functionPointer:Function — This is the function to all with a TopicMessage if the pattern matches, | |
thisContext:Object (default = null ) — When the function is called above, it will retain the this context of what was passed to this method
|
int — true if the message is 'consumed' and should not be relayed to subsequent TopicListeners, nor the default listener.
|
close | () | method |
public function close():void
Close the connection to Diffusion
connect | () | method |
public function connect(connectionDetails:ConnectionDetails):void
Connect to the Diffusion server, using the supplied connection details
Parameters
connectionDetails:ConnectionDetails |
createPagedTopicHandler | () | method |
public function createPagedTopicHandler(message:TopicMessage, listener:PagedTopicListener):PagedTopicHandler
Since : | 4.1 |
Creates a handler object for a 'paged' Topic.
See PagedTopicData for details of paged Topics.
This would be called in response to receiving a Message#isPagedLoad() load message from a paged Topic as a result of subscribing to it. Note that no other messages would be received from a paged Topic until the returned handler is used to PagedTopicHandler#open(int, int) open the Topic.
Parameters
message:TopicMessage — the load message received from the Topic.
| |
listener:PagedTopicListener — an object that is to receive all notifications from the Topic.
|
PagedTopicHandler — the handler which may be used to send requests to the Topic.
|
UnsupportedServerMethodError — UnsupportedServerMethodError
|
createServiceTopicHandler | () | method |
public function createServiceTopicHandler(message:TopicMessage, listener:ServiceTopicListener):ServiceTopicHandler
Since : | 4.1 |
Creates a handler object for a 'Service' Topic.
See ServiceTopicData for details of Service Topics.
This would be called in response to receiving a Message#isServiceLoad() load message from a Service Topic as a result of subscribing to it. Note that no other messages would be received from a Service Topic other than via the specified ServiceTopicListener.
Parameters
message:TopicMessage — the load message received from the Topic.
| |
listener:ServiceTopicListener — an object that is to receive all Service replies and notifications.
|
ServiceTopicHandler — the handler which may be used to send Service requests.
|
UnsupportedServerMethodError — UnsupportedServerMethodError
|
createTopicNotifyTopicHandler | () | method |
public function createTopicNotifyTopicHandler(message:TopicMessage, listener:TopicNotifyListener):TopicNotifyTopicHandler
Since : | 4.6 |
Creates a handler object for a 'TopicNotify' topic.
See TopicNotifyTopicData for details.
This would be called in response to receiving a load message from a notification topic. Note that no other messages would be received from a paged Topic until the returned handler is used to set the level of notifications and the topics to receive notifications for.
Parameters
message:TopicMessage — The load message received from the Topic
| |
listener:TopicNotifyListener — An object that is to receive all notifications from the Topic
|
TopicNotifyTopicHandler — The handler to manage notifications
|
UnsupportedServerMethodError — UnsupportedServerMethodError
|
enableLivenessMonitor | () | method |
public function enableLivenessMonitor(enable:Boolean):void
Enable or disable the connection liveness monitor.
This is disabled by default. The connection liveness monitor will listen for pings from the server, develop an estimate for the ping frequency and raise a disconnection event if a ping is not received within twice the estimated time.
The monitor can be started after connection and will develop an estimate once it has started. It will require at least two pings to generate the first estimate.
Parameters
enable:Boolean — Whether the liveness monitor should be enabled.
|
fetch | () | method |
public function fetch(topic:String, correlationID:String = null):void
Fetch the ITL for the topic. CorrelationID optional, if supplied will be returned in the last user header of the response message Supported by version 3 of the protocol and above
Parameters
topic:String | |
correlationID:String (default = null )
|
UnsupportedServerMethodError — UnsupportedServerMethodError
|
getClientID | () | method |
public function getClientID():String
Get the ID of the connected client
ReturnsString — the Client ID
|
getClientProtocolVersion | () | method |
public function getClientProtocolVersion():int
This returns the client protocol
Returnsint |
getLastInteraction | () | method |
public function getLastInteraction():Number
Returns the time (milliseconds since the epoch) of the last interaction (send or recieve) with the server. Can be 0 if no interaction
ReturnsNumber |
getServerProtocolVersion | () | method |
public function getServerProtocolVersion():int
This returns the protocol version of the server
Returnsint |
getTopicListeners | () | method |
public function getTopicListeners():Array
Gets an array of all topic listeners. This is a shallow copy of interally stored data.
ReturnsArray |
isConnected | () | method |
public function isConnected():Boolean
Returns true if the client is connected
ReturnsBoolean — true is the client is connected
|
onMessage | () | method |
ping | () | method |
public function ping(timeStamp:String = null, queueSize:String = 0):void
Send a ping request to Diffusion, this in turn will respond with a PingMessage
Parameters
timeStamp:String (default = null ) — or null
| |
queueSize:String (default = 0 )
|
See also
reconnect | () | method |
public function reconnect():void
Reconnect to Diffusion if possible.
removeAllTopicListeners | () | method |
public function removeAllTopicListeners():void
Removes all of the topic listeners
removeTopicListener | () | method |
public function removeTopicListener(handle:int):void
Remove the topic listener, with the handle returned from addTopicListener
Parameters
handle:int — The handle of the topic listener
|
reportVersionInformation | () | method |
public function reportVersionInformation():void
send | () | method |
public function send(topic:String, message:String):void
Send a message to a topic
Parameters
topic:String — the topic to send the message
| |
message:String — the message to send to Diffusion
|
sendCredentials | () | method |
public function sendCredentials(credentials:DiffusionClientCredentials):void
Send the credentials to the Diffusion Server. If the credentials are rejected by the sever a ServerRejectedCredentialsEvent will be thrown. Supported by version 2 of the protocol and above
Parameters
credentials:DiffusionClientCredentials |
UnsupportedServerMethodError — UnsupportedServerMethodError
|
sendTopicMessage | () | method |
public function sendTopicMessage(topicMessage:TopicMessage):void
Send a topic message to the server.
Parameters
topicMessage:TopicMessage |
UnsupportedServerMethodError — UnsupportedServerMethodError
|
See also
setAutoAck | () | method |
public function setAutoAck(value:Boolean):void
This method sets if you would like the API to automatically send message acknowledgments back to the server, or if the implementation is going to respond to the Ack's via the acknowledge funciton. If this is set to false then the implementation will need to respond to the Ack Message via the DiffusionClient.acknowledge function
Parameters
value:Boolean |
setConnectionTypes | () | method |
public function setConnectionTypes(socketConnectionType:int, pollingConnectionType:String, cometConnectionType:String):void
Parameters
socketConnectionType:int | |
pollingConnectionType:String | |
cometConnectionType:String |
subscribe | () | method |
public function subscribe(topic:String):void
Parameters
topic:String — the topic to subscribe
|
unsubscribe | () | method |
public function unsubscribe(topic:String):void
Parameters
topic:String — the topic to unsubscribe
|
RELEASE_VERSION | Constant |
public static const RELEASE_VERSION:String = 5.9.4_01
The release version of Diffusion API.