Rate this page:

Accepting an inbound connection

To make inbound WebSocket connections available, use the VoxEngine.allowWebSocketConnections method. Then, subscribe to the AppEvents.WebSocket event. Now you can accept an inbound connection and get a WebSocket object: event.WebSocket.

An accessSecureURL to a WebSocket can be obtained from the HTTP session initialization request or directly from the AppEvents.Started event. Please note that 'https' should be changed to 'wss' in the URL.

When you get the object, you can send data via the WebSocket using the call.sendMediaTo method the same way as we do for an outbound connection.

See the picture below to learn how it all works:

And the code for the scenario will look like this:

WebSocket scenario

WebSocket scenario