Rate this page:

How to send call audio via WebSocket

The Voximplant WebSocket module allows organizing continuous data exchange while keeping the connection open without extra HTTP-requests. And this data can be either text or audio.

Sending call audio via WebSocket

When the connection is open, the call.sendMediaTo method will start sending an audio stream to the WebSocket. Here you can set a preferred encoding format, a tag, and some custom parameters. If you don’t set an encoding, PCM8 will be selected by default. The WebSocket.send method, in turn, will be sending a decoded audio stream in JSON format via the WebSocket. Thus, you’ll be getting messages from the service that handles your requests.

Outbound WebSocket

Outbound WebSocket

In this case, we start sending audio as we get the message confirming that the connection is open.

Inbound WebSocket

Inbound WebSocket

In this case, we start sending audio as we accept the incoming connection and get a WebSocket object.

Setting up Voximplnat side

To implement the WebSocket functionality, you'll need a Voximplant developer account. If you don’t have one, sign up here. Then you'll have to create an application, JS scenario (with the code shown above), rule, and user. When it's been done, log in to your web client or use our webphone as username, and initiate a video call.

Find more details in this section.