Constructor
new module:caplin/services/testing/ConnectionServiceStub(oStreamLinkopt, sInitialStateopt)
Constructs a
caplin.services.testing.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. -
getAvailableStates()
-
Returns the states the ConnectionServiceStub can be in.
-
getCurrentState()
-
Returns the current ConnectionServiceStub connection state
-
getStreamlink()
-
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. -
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(sCallback, pReasons)
-
Notify connection service listeners that the connection status has changed.
Parameters:
Name Type Description sCallback
String The name of the callback function to be triggered in the ConnectionServiceListeners (e.g. 'onConnectionAvailable' or 'onConnectionUnavailable'). pReasons
Array The reason for the change in connection status.