Initializing Vivox
How to initialize Vivox.
읽는 시간 3분최근 업데이트: 19일 전
Use this guide to initialize Vivox and test your integration. The game client must initialize with the Vivox SDK before interacting with it.
1. Set up your message handler
Goal: Create a function to process Vivox messages as they appear. Set up Vivox to handle responses and events via a common callback. Set this callback function via thepf_sdk_message_callbackvx_sdk_config_tvx_initialize3()vx_sdk_config_tvx_get_message()For more details, refer to Message callback.void OnResponseOrEventFromSdk() { int status; vx_message_base_t *msg; for (;;) { status = vx_get_message(&msg); if (status == VX_GET_MESSAGE_AVAILABLE) { if (msg->type == msg_event) { DispatchEvent(reinterpret_cast<vx_evt_base_t *>(msg)); } else { DispatchResponse(reinterpret_cast<vx_resp_base_t *>(msg)); } vx_destroy_message(msg); } else if (status == VX_GET_MESSAGE_FAILURE) { // Handle error here. Occurs if vx_initialize3() has yet to be called. } else { /* VX_GET_MESSAGE_NO_MESSAGE */ break; } }}
2. Call initialize
Goal: Initialize the Vivox SDK. Initialize the Vivox SDK by creating a config variable and passing it tovx_initialize3()VxcErrors.hVxErrorSuccessFor more details, refer to Initialize the Vivox SDK.#include"Vxc.h"#include"VxcErrors.h"vx_sdk_config_t defaultConfig;int status = vx_get_default_config3(&defaultConfig, size of (defaultConfig));if (status != VxErrorSuccess) { printf("vx_sdk_get_default_config3() returned %d: %s\n", status, vx_get_error_string(status)); return;}config.pf_sdk_message_callback = &sOnResponseOrEventFromSdk;status = vx_initialize3(&defaultConfig, size of (defaultConfig));if (status != VxErrorSuccess) { printf("vx_initialize3() returned %d : %s\n", status, vx_get_error_string(status)); return;}// Vivox Client SDK is now initialized
3. Create a connector handle
Goal: Fetch the pre-login server-side configuration file. Create a request object of typevx_req_connector_createconnector_handlevx_resp_connector_createacct_mgmt_serverFor more information, refer to Create the connector object.vx_req_connector_create *req;vx_req_connector_create_create(&req);req->connector_handle = vx_strdup("c1");req->acct_mgmt_server = vx_strdup("https://mt1s.www.vivox.com/api2/");int request_count;int vx_issue_request3_response = vx_issue_request3(&req->base, &request_count);
Verify your implementation
Follow these steps to verify your implementation:- Launch your client application. Navigate past the point where the Vivox SDK should be initialized.
- Set a breakpoint on the SDK message callback or observe a client log file.
- Add or remove an audio headset multiple times.
- Observe that the message callback fires and retrieves events.
vx_get_message() - Navigate past the point where the request is submitted.
connector_create - Verify that the message callback picks up a response.
vx_resp_connector_create - Rerun the test with no internet connection, and verify that error handling and logging work as expected.
connector_create
connector_createstatus_codeIf connector create is unsuccessful
- Print an error to debug log or the client event capture location.
- Attempt to retry initialization.
vx_req_connector_create - Delay for 10 seconds between retries.
- After 5 failed retries, inform the user that voice chat services are not available.
- Retry on the next match or party invite or in 15 minutes, whichever comes first.
- Write the failure to a client log or a server log. Include the .
status_code