Documentation

Support

Vivox Core SDK

Vivox Core SDK

Partial connection failure

Learn how to handle media stream updated events.
Read time 1 minuteLast updated 20 hours ago

In some cases, such as when an application is suspended in the background, the connection to Vivox services can be disrupted so that voice communication terminates without signing out the user. In that case, a
vx_evt_media_stream_updated
event will fire with a state of
session_media_disconnected
and a non-zero
status_code
.
The following sample code is an example of how to handle media stream updated events.
void HandleMediaStreamUpdatedEvent(vx_evt_connection_state_changed &evt){    vx_session_media_state media_state = evt.state;    if (evt.state == session_media_connected)    {        printf("Connected to voice session %s\n", evt.session_handle);    }    else if (evt.state == session_media_disconnected)    {        if (evt.status_code != 0)        {            printf("Disconnected from voice session %s with status %d:%s\n", evt.session_handle, evt.status_code, vx_get_error_string(evt.status_code));            // Expect a session_removed event to follow.            // Wait to re-join the session until after the network connection is restored.        }        else        {            printf("Disconnected from voice session %s\n", evt.session_handle);        }    }}