DEPRECATED: DiffusionTM JavaScript Classic API
5.9.4

Classes

Class DiffusionClientConnectionDetails


DiffusionClientConnectionDetails This class specifies all of the possible connection detail parameters. This class is used as a default and any connection details passed into the connect method of DiffusionClient will be extended by this class


Fields Summary

Boolean autoAck
This flag determines if the Diffusion Client will auto acknowledge messages sent from the server with the Ack / Nak flag set, or if set to false it is down to the client implementation to send the Ack back.
Number cascadeTimeout
This is the timeout (in ms) for cascading if the transport fails to load.
String context
If a Diffusion deployment is in a application server, a context will need to be specified.
Boolean debug
Enable console logging for the connection.
Boolean disableFlash
Disable the flash transport.
Boolean disableForeverFrame
Disable HTTP Forever Frame streaming.
Boolean disableIframe
Disable iFrame transport.
Boolean disableSilverlight
Disable the silverlight transport.
Boolean disableWS
Disable the Web Socket transport.
Boolean disableXHR
Disable the XHR transport.
boolean enableLivenessMonitor
Should the client require system pings to remain connected?

When required if a ping is not received by the time the next one is expected.

String flashHost
The host name of which the flash socket will connect to.
Number flashPort
This is the port of which the flash socket will connect to.
null flashSecure
This indicates if it will attempt a secure Flash socket connection.
Number flashTimeout
This is the number of millis that the socket connection will try before cascading down to HTTP.
String flashTransport
This controls the flash transport. By default it is set to socket.
String flashURL
This is the URL to use if HTTP Transport is to be used within the Flash Player
String libFlashPath
This is the path to the Flash transport library.
String libPath
This is the html path that the Diffusion libraries are stored.
String libSilverlightPath
This is the path to the Silverlight transport library.
string serverHost
This is the the host of which the client will connect to unless overridden by a transport specific value.

This allows all the transports to be configured.

number serverPort
This is the port of which the client will connect to unless overridden by a transport specific value.

This allows all the transports to be configured.

String silverlightHost
The host name of which the silverlight socket will connect to.
Number silverlightPort
This is the port of which the silverlight socket will connect to.
String silverlightTransport
This controls the silverlight transport, by default it is set to cascade, which means that it will try a socket connection first, if that fails, then it will try the HTTP transport.
String silverlightURL
This is the URL to use if HTTP Transport is to be used within the Silverlight Player
Number timeoutMS
This is the number of millis to wait to announce that it was not possible to connect to Diffusion.
String topic
This is the topic to connect to diffusion with.
Number transportTimeout
This is the number of seconds to hold open a XmlHttpRequest / IFrame poll whilst awaiting data.
Number wsTimeout
Connection timeout for web sockets in millis.
String wsURL
This is the Web Socket URL.
Number XHRretryCount
This is the number of retries the XmlHttpRequest transport will make before it announces that it has lost connection with the Diffusion Server.
String XHRURL
This is where it is possible to change where the XmlHttpRequests get served from, if MOD_PROXY not being used and there is a sub domain available.

Constructor Summary

null DiffusionClientConnectionDetails

Method Summary

Function onAbortFunction()
This function is called when the Diffusion Server has terminated the client connected (or the connection has been banned).

This function is supplied with no parameters.

Function onBeforeUnloadFunction()
This function is called when the user closes the browser or navigates away from the page.
Function onCallbackFunction()
This function is called when Diffusion has connected, or exhausted all transports and can not connect.

This function is supplied with two boolean parameters, indicating if the client has connected, and if it is a reconnect.

Function onCascadeFunction()
This function is called when the DiffusionClient cascades transports.

The function is supplied with an argument of the {String} transport name, or NONE if all transport are exhausted.

Function onConnectionRejectFunction()
This function is called when the DiffusionClient connection has been rejected by the Diffusion Server, this is due to incorrect credentials.

This function is called with no parameters.

Function onDataFunction()
This is the function that will be responsible for handling messages from Diffusion.
Function onInvalidClientFunction()
This function is called when an invalid Diffusion operation is called, for instance if Diffusion.subscribe was called before Diffusion.connect(..).

This function is supplied with no parameters.

Function onLostConnectionFunction()
This function is called when the DiffusionClient has lost connection with the Diffusion Server.

This function will be supplied with no parameters.

Function onMessageNotAcknowledgedFunction()
This function is called when a message that has been requested as Acknowledge didn't respond in time.

This function will be supplied with a parameter of the topic message that wasn't acknowledged

Function onPingFunction()
This function is called with an argument of PingMessage when the ping response has been returned from the server.
Function onServerRejectedCredentialsFunction()
This function is called after a DiffusionClient.sendCredentials and the server rejected the credentials.

This function will be supplied with no parameters.

Function onTopicStatusFunction()
This function is called if a topic that a client was subscribed to status has changed (topic removal implemented for now). Status of R returned for removed.

This function will be supplied with one argument of a TopicStatusMessage.

Constructor Details

DiffusionClientConnectionDetails

DiffusionClientConnectionDetails


Field Details

autoAck

Boolean autoAck

This flag determines if the Diffusion Client will auto acknowledge messages sent from the server with the Ack / Nak flag set, or if set to false it is down to the client implementation to send the Ack back.

Default Value:
True

cascadeTimeout

Number cascadeTimeout

This is the timeout (in ms) for cascading if the transport fails to load.

Default Value:
4000

context

String context

If a Diffusion deployment is in a application server, a context will need to be specified.

Default Value:
""

debug

Boolean debug

Enable console logging for the connection.

Default Value:
false

disableFlash

Boolean disableFlash

Disable the flash transport.

Default Value:
false

disableForeverFrame

Boolean disableForeverFrame

Disable HTTP Forever Frame streaming.

Default Value:
false

disableIframe

Boolean disableIframe

Disable iFrame transport.

Default Value:
false

disableSilverlight

Boolean disableSilverlight

Disable the silverlight transport.

Default Value:
false

disableWS

Boolean disableWS

Disable the Web Socket transport.

Default Value:
false

disableXHR

Boolean disableXHR

Disable the XHR transport.

Default Value:
false

enableLivenessMonitor

boolean enableLivenessMonitor

Should the client require system pings to remain connected?

When required if a ping is not received by the time the next one is expected. The lost connection function will be called. This allows browser limitations to be overcome for Forever Frame and IFrame transports where it is not possible to detect the loss or error of an iframe.

Default Value:
false

flashHost

String flashHost

The host name of which the flash socket will connect to.

Default Value:
window.location.hostname

flashPort

Number flashPort

This is the port of which the flash socket will connect to.

Default Value:
window.location.port

flashSecure

flashSecure

This indicates if it will attempt a secure Flash socket connection. The default value is true if the page was loaded using https and false otherwise.


flashTimeout

Number flashTimeout

This is the number of millis that the socket connection will try before cascading down to HTTP.

Default Value:
3000

flashTransport

String flashTransport

This controls the flash transport. By default it is set to socket. This means it will try to create a Flash Socket connection. Values are 'S' for socket, 'C' for HTTP Comet, 'H' for HTTP, any other value will cascade from socket to either HTTP Comet or HTTP. When cascading the protocol of the flashURL property will be used to determine what type of HTTP connection to establish. A protocol of 'http' or 'https' will create a polling connection, a protocol of 'httpc' or 'httpcs' will create an HTTP Comet streaming connection. When the flashTransport is set to HTTP Comet the protocol of flashURL is used only to determine if a secure connection should be established.

Default Value:
"S"

flashURL

String flashURL

This is the URL to use if HTTP Transport is to be used within the Flash Player

Default Value:
location.protocol + "//" + location.host

libFlashPath

String libFlashPath

This is the path to the Flash transport library. The value set will be appended to the value of DiffusionClientConnectionDetails.libPath and used when connecting over the Flash transport.

Default Value:
"${diffusion.client.flash.name}"

libPath

String libPath

This is the html path that the Diffusion libraries are stored.

Default Value:
"/lib/DIFFUSION"

libSilverlightPath

String libSilverlightPath

This is the path to the Silverlight transport library. The value set will be appended to the value of DiffusionClientConnectionDetails.libPath and used when connecting over the Silverlight transport.

Default Value:
"${diffusion.client.silverlight.name}"

serverHost

string serverHost

This is the the host of which the client will connect to unless overridden by a transport specific value.

This allows all the transports to be configured. For example:

DiffusionClient.connect({serverHost : "example.org", serverPort : 8070});

Will connect to ws://example.org:8070 using websockets.

Will connect to example.org at 8070 using Flash sockets.

Will connect to http://example.org:8070 using Flash HTTP.

Will connect to example.org at 4503 using Silverlight sockets.

Will connect to http://example.org:8070 using Silverlight HTTP.

Will connect to http://example.org:8070 using XHR.

Silverlight sockets have a limited port range and serverPort will only set this value if it is within this range.

DiffusionClient.connect({serverHost : "example.org", serverPort : 8070, flashPort : 4505, silverlightPort : 4505});

Will connect both the Flash and Silverlight sockets to example.org at 4505.

The HTTP transports assume the same protocol as the page is loaded with.

Default Value:
window.location.hostname

serverPort

number serverPort

This is the port of which the client will connect to unless overridden by a transport specific value.

This allows all the transports to be configured. For example:

DiffusionClient.connect({serverHost : "example.org", serverPort : 8070});

Will connect to ws://example.org:8070 using websockets.

Will connect to example.org at 8070 using Flash sockets.

Will connect to http://example.org:8070 using Flash HTTP.

Will connect to example.org at 4503 using Silverlight sockets.

Will connect to http://example.org:8070 using Silverlight HTTP.

Will connect to http://example.org:8070 using XHR.

Silverlight sockets have a limited port range and serverPort will only set this value if it is within this range.

DiffusionClient.connect({serverHost : "example.org", serverPort : 8070, flashPort : 4505, silverlightPort : 4505});

Will connect both the Flash and Silverlight sockets to example.org at 4505.

The HTTP transports assume the same protocol as the page is loaded with.

Default Value:
window.location.port

silverlightHost

String silverlightHost

The host name of which the silverlight socket will connect to.

Default Value:
window.location.hostname

silverlightPort

Number silverlightPort

This is the port of which the silverlight socket will connect to.

Default Value:
4503

silverlightTransport

String silverlightTransport

This controls the silverlight transport, by default it is set to cascade, which means that it will try a socket connection first, if that fails, then it will try the HTTP transport. Valid values are S socket, H HTTP, C cascade.

Default Value:
"S"

silverlightURL

String silverlightURL

This is the URL to use if HTTP Transport is to be used within the Silverlight Player

Default Value:
location.protocol + "//" + location.host

timeoutMS

Number timeoutMS

This is the number of millis to wait to announce that it was not possible to connect to Diffusion.

Default Value:
4000

topic

String topic

This is the topic to connect to diffusion with.

Default Value:
null

transportTimeout

Number transportTimeout

This is the number of seconds to hold open a XmlHttpRequest / IFrame poll whilst awaiting data.

Default Value:
90

wsTimeout

Number wsTimeout

Connection timeout for web sockets in millis.

Default Value:
2000

wsURL

String wsURL

This is the Web Socket URL.

Default Value:
"ws://" + location.host

XHRretryCount

Number XHRretryCount

This is the number of retries the XmlHttpRequest transport will make before it announces that it has lost connection with the Diffusion Server.

Default Value:
3

XHRURL

String XHRURL

This is where it is possible to change where the XmlHttpRequests get served from, if MOD_PROXY not being used and there is a sub domain available.

Default Value:
location.protocol + "//" + location.host

Method Details

onAbortFunction

Function onAbortFunction()

This function is called when the Diffusion Server has terminated the client connected (or the connection has been banned).

This function is supplied with no parameters.


onBeforeUnloadFunction

Function onBeforeUnloadFunction()

This function is called when the user closes the browser or navigates away from the page.


onCallbackFunction

Function onCallbackFunction()

This function is called when Diffusion has connected, or exhausted all transports and can not connect.

This function is supplied with two boolean parameters, indicating if the client has connected, and if it is a reconnect.

Examples
var details = new DiffusionClientConnectionDetails();
details.onCallbackFunction = function(isConnected, isReconnect) {
	if (isConnected) {
		// We know we're connected

		if (!isReconnect) {
			// If we're connecting for the first time, init stuff
		}
	}
}

onCascadeFunction

Function onCascadeFunction()

This function is called when the DiffusionClient cascades transports.

The function is supplied with an argument of the {String} transport name, or NONE if all transport are exhausted.


onConnectionRejectFunction

Function onConnectionRejectFunction()

This function is called when the DiffusionClient connection has been rejected by the Diffusion Server, this is due to incorrect credentials.

This function is called with no parameters.


onDataFunction

Function onDataFunction()

This is the function that will be responsible for handling messages from Diffusion. This function will be called with a argument of WebClientMessage. This function will be called even if there is a topic listener in place for a topic.

Examples
var details = new DiffusionClientConnectionDetails();
details.onDataFunction = function(msg) {
	// Do something
}

onInvalidClientFunction

Function onInvalidClientFunction()

This function is called when an invalid Diffusion operation is called, for instance if Diffusion.subscribe was called before Diffusion.connect(..).

This function is supplied with no parameters.


onLostConnectionFunction

Function onLostConnectionFunction()

This function is called when the DiffusionClient has lost connection with the Diffusion Server.

This function will be supplied with no parameters.


onMessageNotAcknowledgedFunction

Function onMessageNotAcknowledgedFunction()

This function is called when a message that has been requested as Acknowledge didn't respond in time.

This function will be supplied with a parameter of the topic message that wasn't acknowledged


onPingFunction

Function onPingFunction()

This function is called with an argument of PingMessage when the ping response has been returned from the server.


onServerRejectedCredentialsFunction

Function onServerRejectedCredentialsFunction()

This function is called after a DiffusionClient.sendCredentials and the server rejected the credentials.

This function will be supplied with no parameters.


onTopicStatusFunction

Function onTopicStatusFunction()

This function is called if a topic that a client was subscribed to status has changed (topic removal implemented for now). Status of R returned for removed.

This function will be supplied with one argument of a TopicStatusMessage.