Class: VoiceWebSocket

VoiceWebSocket

Represents a Voice Connection's WebSocket.

Constructor

(private) new VoiceWebSocket()

Source:

Extends

  • EventEmitter

Members

attempts :number

How many connection attempts have been made
Type:
  • number
Source:

(readonly) client :Client

The client of this voice WebSocket
Type:
Source:

connection :VoiceConnection

The Voice Connection that this WebSocket serves
Type:
Source:

ws :WebSocket

The actual WebSocket used to connect to the Voice WebSocket Server.
Type:
  • WebSocket
Source:

Methods

clearHeartbeat()

Clears a heartbeat interval, if one exists.
Source:

connect()

Starts connecting to the Voice WebSocket Server.
Source:

onClose()

Called whenever the connection to the WebSocket server is lost.
Source:

onError(error)

Called whenever an error occurs with the WebSocket.
Parameters:
Name Type Description
error Error The error that occurred
Source:

onMessage(event) → {void}

Called whenever a message is received from the WebSocket.
Parameters:
Name Type Description
event MessageEvent The message event that was received
Source:
Returns:
Type
void

onOpen()

Called whenever the WebSocket opens.
Source:

onPacket(packet)

Called whenever a valid packet is received from the WebSocket.
Parameters:
Name Type Description
packet Object The received packet
Source:

reset()

Resets the current WebSocket.
Source:

send(data) → {Promise.<string>}

Sends data to the WebSocket if it is open.
Parameters:
Name Type Description
data string The data to send to the WebSocket
Source:
Returns:
Type
Promise.<string>

sendHeartbeat()

Sends a heartbeat packet.
Source:

sendPacket(packet) → {Promise.<string>}

JSON.stringify's a packet and then sends it to the WebSocket Server.
Parameters:
Name Type Description
packet Object The packet to send
Source:
Returns:
Type
Promise.<string>

setHeartbeat(interval)

Sets an interval at which to send a heartbeat packet to the WebSocket.
Parameters:
Name Type Description
interval number The interval at which to send a heartbeat packet
Source:

Events

ready

Emitted once the voice WebSocket receives the ready packet.
Parameters:
Name Type Description
packet Object The received packet
Source:

sessionDescription

Emitted once the Voice Websocket receives a description of this voice session.
Parameters:
Name Type Description
packet Object The received packet
Source:

startSpeaking

Emitted whenever a speaking packet is received.
Parameters:
Name Type Description
data Object
Source:

unknownPacket

Emitted when an unhandled packet is received.
Parameters:
Name Type Description
packet Object
Source:

warn

Emitted whenever the voice WebSocket encounters a non-fatal error.
Parameters:
Name Type Description
warn string The warning
Source: