Send data through text messages
Learn how to send structured data using text messages.
Read time 1 minuteLast updated 20 hours ago
Vivox text messages can send additional, non-messaging data through two string variables:
- Application stanza namespace
- Application stanza body
You can hide messages if you need to keep them hidden from users. For example, you are using them only to send data with no visible message. One method to accomplish this is to label your application stanza namespace accordingly. For example, you can have an application stanza namespace named "
data:hiddenmessage:omit
You can access the hidden data after it is received. You can access its application stanza body by grabbing the message from the function that receives it.
Core application stanza body
The following examples detail how to send hidden data through text messages and access hidden data from messages in the Vivox Core SDK.Send hidden data in messages
string applicationStanzaNamespace = "team:color";string applicationStanzaBody = teamColor; //"red" or "blue"vx_req_account_send_message_t *req;vx_req_account_send_message_create(&req);req->account_handle = vx_strdup(accountHandle.c_str());req->message_body = vx_strdup(message.c_str());req->user_uri = vx_strdup(user.c_str());req->application_stanza_namespace = vx_strdup(applicationStanzaNamespace);req->application_stanza_body = vx_strdup(applicationStanzaBody);IssueRequest(&req->base);
Access hidden data from messages
if(evt->type == evt_message){ vx_evt_message *tevt = (vx_evt_message *)evt; if ( tevt->application_stanza_namespace == "team:color") { if( tevt->application_stanza_body == "blue") { //assign font blue } else if( tevt->application_stanza_body == "red") { //assign font red } else { //assign font grey } }}
SDKSampleApp
These examples mimic theSDKSampleApp::HandleMessage(vx_message_base_t *msg)