Requests and responses
Learn about requests and responses in Vivox.
Read time 1 minuteLast updated 7 months 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 request is created by calling the function. The request is then sent to the Vivox SDK by calling .
vx_req_account_anonymous_loginvx_req_account_anonymous_login_create()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 is called, the Vivox SDK posts a message back to the game. Each message that the game processes could be the response to one of multiple different requests. The game determines the true type of the message by looking at the field, and then casts that message to the corresponding specific response structure.
vx_issue_request3()vx_resp_base_tvx_resp_base_tvx_resp_base_tvx_resp_base_t.typeThe convention for mapping values to response types is to use the following format: if the value is , then the corresponding structure type is .
vx_response_typevx_response_typeesp_xxxvx_resp_xxx_tThe 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 and the fields.
return_codestatus_codeThe 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.