WebSocketEvents
Add the following line to your scenario code to use the events:
require(Modules.WebSocket);
Constants
CLOSE
Event is triggered when the WebSocket connection is closed. WebSocket.onclose will be called right before any other handlers.
Parameters
code:
WebSocket close code.
reason:
string
Reason why the connection was closed.
wasClean:
boolean
Value indicating whether the connection was cleanly closed.
websocket:
WebSocket object that triggered the event.
ERROR
Event is triggered when an error occurs on the WebSocket connection. WebSocket.onerror will be called right before any other handlers.
Parameters
websocket:
WebSocket object that triggered the event.
MEDIA_ENDED
Event is triggered after the end of the audio stream sent by a third party through a WebSocket (1 second of silence).
Parameters
mediaInfo:
Information about the audio stream that can be obtained after the stream stops or pauses (1-sec silence).
tag:
string
Special tag to name audio streams sent over one WebSocket connection. Using it, one can send 2 audios to 2 different calls at the same time.
websocket:
WebSocket object that triggered the event.
MEDIA_STARTED
Event is triggered when the audio stream sent by a third party through a WebSocket is started playing.
Parameters
customParameters:
{[key: string]: string}
Custom data.
tag:
string
Special tag to name audio streams sent over one WebSocket connection. Using it, one can send 2 audios to 2 different calls at the same time.
websocket:
WebSocket object that triggered the event.
MESSAGE
Event is triggered when a message is received by a target object. WebSocket.onmessage will be called right before any other handlers.
Parameters
data:
string
The data sent by the message emitter.
websocket:
WebSocket object that triggered the event.
OPEN
Event is triggered when the WebSocket connection is opened. WebSocket.onopen will be called right before any other handlers.
Parameters
websocket:
WebSocket object that triggered the event.