new module:ct-services /testing /Connection Service Stub(oStream Linkopt, sInitial Stateopt)
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
add Status Changed Listener(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. |
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:
get Available States()
Returns the states the ConnectionServiceStub can be in.
get Current State()
Returns the current ConnectionServiceStub connection state
get Streamlink()
Return Streamlink instance.
get Valid Transitions(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 |
remove Status Changed Listener(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. |
set State(sNew State)
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 |
update Status(callback Name, arg List)
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. |