DEPRECATED: DiffusionTM JavaScript Classic API
5.9.4

Classes

Class DiffusionClient


This is the DiffusionClient singleton. DiffusionClient class


Fields Summary

static Boolean isFirefox
True if browser Firefox
static Boolean isIE
True if browser is IE
static Boolean isIE9
True if browser IE9
static Boolean isWindows
True if platform is windows

Constructor Summary

null DiffusionClient

Method Summary

static null acknowledge(WebClientMessage)
Send a message acknowledgement back to the server.
static int addServiceListener(regex, function, thisContext)
Add a service listener
static int addTimedTopicListener(regex, functionPointer, time, force, thisContext)
Add a Timed Topic listener
static int addTopicListener(regex, function, context)
Add a topic listener
static function bind(function, context)
Bind a function to a given context
static null close()
Close the connection
static null command(command, correlationID, TopicMessage)
Send a command message.
static null connect(connectionDetails, credentials)
Connect to Diffusion using a DiffusionClientConnectionDetails Object, with optional credentials
static PagedTopicHandler createPagedTopicHandler(topicName, listener)
Create a handler for a paged topic data topic.
static number createServiceTopicHandler(TopicMessage, function)
Adds a Service topic listener, taking the topic from the supplied message.
static TopicNotifyTopicHandler createTopicNotifyTopicHandler(message, listener)
Creates a handler for topic notifications.
static Object extend(objA, objB)
Extends objA by copying all properties of objB to objA.
static null fetch(topic, correlationID)
Fetch topic state on a given topic.
static String getClientID()
Get the current client ID
static number getClientProtocolVersion()
Get the client protocol version
static DiffusionClientCredentials getCredentials()
Get the credentials for this client
static number getLastInteraction()
Gets the last time (milliseconds since epoch) there was any interaction between the client and the server
static number getServerProtocolVersion()
Get the server protocol version
static String getTransportName()
Get the name of the current transport
static Websocket getWebSocket(url)
Returns the Web Socket object (if any).
static Boolean hasFlash(version)
Detect if flash present, with the minimum version passed as a parameter
static Boolean hasSilverlight()
Detect if Silverlight present, this currently looks for version 4.0.5 or above
static Boolean isConnected()
Check if the Diffusion Client is currently connected
static Boolean isReconnected()
Check if the Diffusion Client is connected as a result of reconnection
static Boolean isTransportValid()
Check if the current transport being used by Diffusion Client is valid
static null page(Type, TopicMessage)
Send a page message.
static null ping()
Send a ping request to the Diffusion server.
static null reconnect()
Reconnect to Diffusion using existing DiffusionClientConnectionDetails and Client ID.
static null removeAllTopicListeners()
Remove all topic listeners This function would be required, if the connection was lost and the client was going to used to re-connect
static null removePagedTopicHandler(handler)
Remove the handler and unsubscribe from the paged topic.
static null removeTimedTopicListener(handle)
Remove the Timed topic listener
static null removeTopicListener(handle)
Remove the topic listener
static null send(topic, message)
Send a message to the Diffusion Server on a given topic with the specified message
static null sendCredentials(credentials)
Send a credentials message to the Diffusion Server
static null sendTopicMessage(TopicMessage)
Send TopicMessage.
static null setCredentials(DiffusionClientCredentials)
Set the user credentials
static null setDebugging(value)
Set debugging for Diffusion
static null subscribe(topic)
Subscribe to a topic.
static String timestamp()
Format current time in timestamp format of HH:mm:ss.SS
static null trace(message)
Send output to the Debug Console
static null unsubscribe(topic)
Unsubscribe from a topic

Constructor Details

DiffusionClient

DiffusionClient


Field Details

isFirefox

static Boolean isFirefox

True if browser Firefox


isIE

static Boolean isIE

True if browser is IE


isIE9

static Boolean isIE9

True if browser IE9


isWindows

static Boolean isWindows

True if platform is windows


Method Details

acknowledge

static acknowledge(WebClientMessage)

Send a message acknowledgement back to the server. This will be required if autoAck is set to false

Parameters
WebClientMessage - The WebClientMessage to acknowledge

addServiceListener

static int addServiceListener(regex, function, thisContext)

Add a service listener

Parameters
regex - The regex is a String representation of a matches regex pattern on the topic name. For an exact match, use ^topicname$
function - This is the function to call with a WebClientMessage if the pattern matches
thisContext - When the function is called above, it will retain the this context of what was passed to this method

addTimedTopicListener

static int addTimedTopicListener(regex, functionPointer, time, force, thisContext)

Add a Timed Topic listener

Parameters
regex - The regex is a String representation of a matches regex pattern on the topic name. For an exact match, use ^topicname$
functionPointer - This is the function to all with a WebClientMessage if the pattern matches
time - Interval in millisecond to call the @function.
force - Call the @function even if any message has been received
thisContext - When the function is called above, it will retain the this context of what was passed to this method

addTopicListener

static int addTopicListener(regex, function, context)

Add a topic listener

Parameters
regex - The regex is a String representation of a matches regex pattern on the topic name. For an exact match, use ^topicname$
function - This is the function to all with a WebClientMessage if the pattern matches
context - When the function is called above, it will retain the this context of what was passed to this method

bind

static function bind(function, context)

Bind a function to a given context

Parameters
function -
context -

close

static close()

Close the connection


command

static command(command, correlationID, TopicMessage)

Send a command message. The topic message contains the topic name, headers and message body to be sent to the Diffusion server.

Parameters
command - The command to send
correlationID -
TopicMessage - See TopicMessage

connect

static connect(connectionDetails, credentials)

Connect to Diffusion using a DiffusionClientConnectionDetails Object, with optional credentials

Parameters
connectionDetails - See connection details class for more information DiffusionClientConnectionDetails
credentials - See client credentials class for more information DiffusionClientCredentials
Examples
DiffusionClient.connect({ topic : "Fred", onDataFunction: function(msg){ // do something } });
DiffusionClient.connect({ topic : "Fred", onDataFunction: function(msg){ // do something } }, { username : "Bert", password : "admin" });

createPagedTopicHandler

static PagedTopicHandler createPagedTopicHandler(topicName, listener)

Create a handler for a paged topic data topic.

The handler is created asynchronously. The ready callback of the listener should be used for the code that you run when the handler is created.

Parameters
topicName - The name of the paged topic
listener - The PageTopicListener to use
Since:
5.0

createServiceTopicHandler

static number createServiceTopicHandler(TopicMessage, function)

Adds a Service topic listener, taking the topic from the supplied message.

Parameters
TopicMessage - The message from which the appropriate Topic is taken.
function - The handler function that will be called by the listener

createTopicNotifyTopicHandler

static TopicNotifyTopicHandler createTopicNotifyTopicHandler(message, listener)

Creates a handler for topic notifications.

Parameters
message - The ITL for the notification topic
listener - The listener object
Since:
4.6

extend

static Object extend(objA, objB)

Extends objA by copying all properties of objB to objA.

Parameters
objA -
objB -

fetch

static fetch(topic, correlationID)

Fetch topic state on a given topic. This data will arrive on the onData method and any topic listeners

Parameters
topic - or TopicSet expression
correlationID -

getClientID

static String getClientID()

Get the current client ID


getClientProtocolVersion

static number getClientProtocolVersion()

Get the client protocol version


getCredentials

static DiffusionClientCredentials getCredentials()

Get the credentials for this client


getLastInteraction

static number getLastInteraction()

Gets the last time (milliseconds since epoch) there was any interaction between the client and the server


getServerProtocolVersion

static number getServerProtocolVersion()

Get the server protocol version


getTransportName

static String getTransportName()

Get the name of the current transport


getWebSocket

static Websocket getWebSocket(url)

Returns the Web Socket object (if any).

Parameters
url -

hasFlash

static Boolean hasFlash(version)

Detect if flash present, with the minimum version passed as a parameter

Parameters
version - The minimum version required

hasSilverlight

static Boolean hasSilverlight()

Detect if Silverlight present, this currently looks for version 4.0.5 or above


isConnected

static Boolean isConnected()

Check if the Diffusion Client is currently connected


isReconnected

static Boolean isReconnected()

Check if the Diffusion Client is connected as a result of reconnection


isTransportValid

static Boolean isTransportValid()

Check if the current transport being used by Diffusion Client is valid


page

static page(Type, TopicMessage)

Send a page message. This is a variant of a command message, but does not require a correlation ID.

Parameters
Type - The page command type (e.g. "O", "R", "N", etc)
TopicMessage - See TopicMessage

ping

static ping()

Send a ping request to the Diffusion server. The response to this will be a PingMessage


reconnect

static reconnect()

Reconnect to Diffusion using existing DiffusionClientConnectionDetails and Client ID. Utilises existing onCallbackFunction to indicate success or failure, with a second boolean parameter to denote that this is a reconnect result. Example for automatic reconnecting: DiffusionClient.connect({ onCallbackFunction : function( isConnected, isReconnect) { if( !isConnected && isReconnect ) DiffusionClient.reconnect(); } }, onLostConnectionFunction : function() { DiffusionClient.reconnect(); } });


removeAllTopicListeners

static removeAllTopicListeners()

Remove all topic listeners This function would be required, if the connection was lost and the client was going to used to re-connect


removePagedTopicHandler

static removePagedTopicHandler(handler)

Remove the handler and unsubscribe from the paged topic.

Parameters
handler - The handler to remove
Since:
5.0

removeTimedTopicListener

static removeTimedTopicListener(handle)

Remove the Timed topic listener

Parameters
handle -

removeTopicListener

static removeTopicListener(handle)

Remove the topic listener

Parameters
handle -

send

static send(topic, message)

Send a message to the Diffusion Server on a given topic with the specified message

Parameters
topic -
message -

sendCredentials

static sendCredentials(credentials)

Send a credentials message to the Diffusion Server

Parameters
credentials -

sendTopicMessage

static sendTopicMessage(TopicMessage)

Send TopicMessage.

Parameters
TopicMessage - See TopicMessage

setCredentials

static setCredentials(DiffusionClientCredentials)

Set the user credentials

Parameters
DiffusionClientCredentials - The credentials to be supplied

setDebugging

static setDebugging(value)

Set debugging for Diffusion

Parameters
value -

subscribe

static subscribe(topic)

Subscribe to a topic. If a subscription is made to an already subscribed topic, this method is a no-op.

Parameters
topic - or TopicSet pattern

timestamp

static String timestamp()

Format current time in timestamp format of HH:mm:ss.SS


trace

static trace(message)

Send output to the Debug Console

Parameters
message -

unsubscribe

static unsubscribe(topic)

Unsubscribe from a topic

Parameters
topic - or TopicSet pattern