Caplin Trader 5.1.0

Class: module:ct-services/testing/ConnectionServiceStub

module:ct-services/testing/ConnectionServiceStub(oStreamLinkopt, sInitialStateopt)

new module:ct-services/testing/ConnectionServiceStub(oStreamLinkopt, sInitialStateopt)

Constructs a ConnectionServiceStub.

The ConnectionServiceStub serves to create a stub for a ConnectionService to enable tests to simulate connection status changes.

Parameters:
Name Type Attributes Description
oStreamLink Object <optional>

The Streamlink instance to be used.

sInitialState String <optional>

The initial state for the ConnectionServiceStub.

Implements:

Methods

addStatusChangedListener(fCallback)

Add a function as listener to connection status changes.

Parameters:
Name Type Description
fCallback function

The callback that is used to notify of connection status changes.

Implements:

connect()

Connects to the connection service, or do nothing if already connected.

Implements:

disconnect()

Disconnects from the connection service or do nothing if already disconnected.

Implements:

dispose()

Disposes of any listeners and resources that were used by the service.

Implements:

getAvailableStates()

Returns the states the ConnectionServiceStub can be in.

getCurrentState()

Returns the current ConnectionServiceStub connection state

Return Streamlink instance.

getValidTransitions(The)

Returns the available states that can be transitioned from the state given. If no state is given it will return the available transitions from the current state.

Parameters:
Name Type Description
The String

state from which we want to know the transitions

removeStatusChangedListener(fCallback)

Remove a function as listener to connection status changes.

Parameters:
Name Type Description
fCallback function

The callback that is used to notify of connection status changes.

Implements:

setState(sNewState)

Sets a connection state from the available ones ('OK', 'ERROR', 'PARTIAL', 'DOWN') and notifies the listeners of a connection status change.

Parameters:
Name Type Description
sNewState String

The new state to be set

updateStatus(callbackName, argList)

Notify connection service listeners that the connection status has changed.

Parameters:
Name Type Description
callbackName String

The name of the callback function to be triggered in the ConnectionServiceListeners (e.g. 'onConnectionAvailable' or 'onConnectionUnavailable').

argList Array

The arguments to send to the observer's callback.