Network connection state events
Learn about network connection state events.
Read time 2 minutesLast updated 20 hours ago
The Vivox SDK provides details on the network connection status through network connection state events, which are informational and require no immediate action. These events are intended to supplement the game’s own notion of network reachability. They provide visibility into the Vivox SDK’s internal automatic connection recovery process under the following conditions:
-
The initial network connection to Vivox services has been established after .
vx_req_account_anonymous_login - The network connection recovery process has begun.
- Either the network connection has been restored, or reconnection attempts have failed.
-
: Sent when a change has occurred in the connection to Vivox services.
vx_evt_connection_state_changed -
:
connection_state-
: Initial network connection has been established after vx_req_account_anonymous_login. Network-dependent API calls are safe.
connection_state_connected -
: Attempting to reestablish a connection to Vivox services. Avoid making network-dependent API calls until the connection has recovered or has failed to recover, otherwise undefined behavior can result.
connection_state_recovering -
: Failed to reestablish network connection to Vivox services. A logged_out event will follow. Wait to sign in again until after the game’s network connection has been restored.
connection_state_failed_to_recover -
: Network connection to Vivox services has been successfully reestablished. Network-dependent API calls are safe.
connection_state_recovered
-
-
: The handle of a user who is signed in.
account_handle
void HandleConnectionStateChangedEvent(vx_evt_connection_state_changed &evt){ vx_connection_state connection_state = evt.connection_state; switch (connection_state) { case connection_state_connected: printf("%s is connected to Vivox\n", evt.acct_handle); // All API calls are safe to make break; case connection_state_recovering: printf("Network connection recovering\n"); // Avoid making network-dependent API calls while the connection is recovering, such as login, logout, add_session, or remove_session. break; case connection_state_failed_to_recover: printf("Network connection failed to recover\n"); // Expect a logged_out event to follow // Wait to login until after the network connection is restored break; case connection_state_recovered: printf("Reconnected to network\n"); // All API calls are safe to make break; }}