Skip to content

bodhi-realtime-agent / ClientTransport

Class: ClientTransport

Defined in: transport/client-transport.ts:30

WebSocket server that bridges a client audio app to the framework.

Multiplexes two message types on the same WebSocket connection:

  • Binary frames: Raw PCM audio (forwarded via onAudioFromClient or buffered during transfers).
  • Text frames: JSON messages for GUI events (onJsonFromClient).

Buffering mode (startBuffering/stopBuffering) only affects binary audio frames. Text frames are always delivered immediately.

Constructors

Constructor

new ClientTransport(port, callbacks, host, listenTimeoutMs): ClientTransport

Defined in: transport/client-transport.ts:36

Parameters

port

number

callbacks

ClientTransportCallbacks

host

string = '0.0.0.0'

listenTimeoutMs

number = 10_000

Returns

ClientTransport

Accessors

buffering

Get Signature

get buffering(): boolean

Defined in: transport/client-transport.ts:137

Returns

boolean


isClientConnected

Get Signature

get isClientConnected(): boolean

Defined in: transport/client-transport.ts:133

Returns

boolean

Methods

sendAudioToClient()

sendAudioToClient(data): void

Defined in: transport/client-transport.ts:110

Send raw PCM audio to the client as a binary frame.

Parameters

data

Buffer

Returns

void


sendJsonToClient()

sendJsonToClient(message): void

Defined in: transport/client-transport.ts:117

Send a JSON message to the client as a text frame.

Parameters

message

Record<string, unknown>

Returns

void


start()

start(): Promise<void>

Defined in: transport/client-transport.ts:43

Returns

Promise<void>


startBuffering()

startBuffering(): void

Defined in: transport/client-transport.ts:123

Returns

void


stop()

stop(): Promise<void>

Defined in: transport/client-transport.ts:91

Returns

Promise<void>


stopBuffering()

stopBuffering(): Buffer<ArrayBufferLike>[]

Defined in: transport/client-transport.ts:128

Returns

Buffer<ArrayBufferLike>[]

Built with VitePress