VoiceAgentWebSocketTransport interface
A pluggable WebSocket transport used by VoiceAgentRealtimeClient. Implement this interface to customize how the realtime connection is established, for example to route it through an authenticated relay.
Methods
| close(number, string) | Closes the connection. |
| connect(Voice |
Establishes the WebSocket connection. |
| send(string, Abort |
Sends a message over the connection. |
| set |
Registers the handlers invoked as connection events occur. |
Method Details
close(number, string)
Closes the connection.
function close(code: number, reason: string): Promise<void>
Parameters
- code
-
number
- reason
-
string
Returns
Promise<void>
connect(VoiceAgentWebSocketConnectOptions)
Establishes the WebSocket connection.
function connect(options: VoiceAgentWebSocketConnectOptions): Promise<void>
Parameters
Returns
Promise<void>
send(string, AbortSignalLike)
Sends a message over the connection.
function send(data: string, abortSignal?: AbortSignalLike): Promise<void>
Parameters
- data
-
string
- abortSignal
- AbortSignalLike
Returns
Promise<void>
setHandlers(VoiceAgentWebSocketHandlers)
Registers the handlers invoked as connection events occur.
function setHandlers(handlers: VoiceAgentWebSocketHandlers)
Parameters
- handlers
- VoiceAgentWebSocketHandlers