Documentation

Support

Vivox Core SDK

Vivox Core SDK

Requests and responses

Learn about requests and responses in Vivox.
Read time 1 minuteLast updated 20 hours ago

The Vivox SDK supports various requests that you can use to control its behavior. For each request issued to the Vivox SDK, there is a response that the game processes as a part of its response handler. Requests are created by using functions that are closely named to the type of request. For example, the
vx_req_account_anonymous_login
request is created by calling the
vx_req_account_anonymous_login_create()
function. The request is then sent to the Vivox SDK by calling
vx_issue_request3()
.
The following code displays an example of this process:
. . .vx_req_account_anonymous_login_t *req;vx_req_account_anonymous_login_create(&req);req->account_name = vx_strdup(".myissuer.myid.");req->account_handle = vx_strdup(".myid.");req->connector_handle = vx_strdup("c1");vx_issue_request3(&req->base, &request_count);. . .
When
vx_issue_request3()
is called, the Vivox SDK posts a
vx_resp_base_t
message back to the game. Each
vx_resp_base_t
message that the game processes could be the response to one of multiple different requests. The game determines the true type of the
vx_resp_base_t
message by looking at the
vx_resp_base_t.type
field, and then casts that message to the corresponding specific response structure.
The convention for mapping
vx_response_type
values to response types is to use the following format: if the
vx_response_type
value is
esp_xxx
, then the corresponding structure type is
vx_resp_xxx_t
.
The following code displays an example of this process:
void MyGamesResponseHandler(vx_resp_base_t *resp){ switch(resp->type) { case resp_connector_create: { vx_resp_connector_create_t *tresp =reinterpret_cast<vx_resp_connector_create_t *>(resp); // handle the response here. break; } case resp_account_anonymous_login: { // etc break; } }}
When the Vivox SDK returns a response, configure the application to check the
return_code
and the
status_code
fields.
The following code displays an example of this process:
. . .vx_resp_base_t *resp;. . .if (resp->base.return_code == 1){ // This is a failure printf("resp type %s returned %d: %s\n", vx_get_response_type_string(resp->base.type), resp->base.status_code, vx_get_error_string(resp->base.status_code)); return;}
For a mapping of all possible messages to common game functionality, refer to Request, response, and event mapping to Vivox functionality.