Documentation

​
​

Development

User Acquisition

Monetization

Industry

Vivox Core SDK

Vivox Core SDK

Vivox
​
​
Vivox Core SDK
  • Overview
  • Before you begin
  • Get started
  • Release notes
  • Developer Guide
    • Client SDK basics
      • Initialize the Vivox SDK
      • Handle messages
        • Message callback
        • Message polling
      • Message types
      • Character encoding
      • Requests and responses
      • Create the connector object
      • Sign in to a game
      • Sign out of a game
      • Uninitialize the Vivox SDK
    • Channels
    • Presence management
    • Messaging
    • Manage audio
    • Couch co-op
    • Android app development
    • iOS app development
    • macOS app development
    • Windows app development
    • Real-time recording
    • Speech-to-text audio transcription
    • Text-to-speech
    • Troubleshooting
  • Reference
  • Privacy overview
  1. Vivox Core SDK documentation

Message callback

Understand how to use message callback to handle messages.
Read time 2 minutes
Last updated 8 months ago

When you initialize the Vivox SDK, you need to set up your implementation to handle SDK messages. Using a callback method is the suggested best practice. This simplifies your game logic by only responding to messages when they occur, rather than using a polling loop that might be idle most of the time.
The callback is a parameter for
vx_sdk_config_t
, which is shown in the following
VxcTypes.h
example:
// When the SDK message callback is called, call vx_get_message() until there are no more messages. void (*pf_sdk_message_callback)(void *callback_handle);
The following example is built on code from the SDKSampleApp with extra details on using OnSdkMessageAvailable on a ListenerThread:
static vx_sdk_config_t MakeConfig(const SDKSampleApp &app, unsigned int default_codecs_mask, vx_log_level log_level = log_error){ vx_sdk_config_t config; vx_get_default_config3(&config, sizeof(config)); config.pf_logging_callback = OnLog; config.pf_sdk_message_callback = OnSdkMessageAvailable;}void OnSdkMessageAvailable(void *callbackHandle){ SDKSampleApp *app = reinterpret_cast<SDKSampleApp *>(callbackHandle); app->set_event(m_messageAvailableEvent);}void SDKSampleApp::ListenerThread(){ for (; m_started;) // Pulls a message from the queue. If no message found, waits until notified, then tries again. { wait_event(m_messageAvailableEvent, -1); for (;;) { vx_message_base_t *msg = NULL; vx_get_message(&msg); // Type of message, and then type of the Event or Response is discovered, and the // appropriate call is made to process that message type. if (msg == NULL) { break; } Lock(); HandleMessage(msg); Unlock(); vx_destroy_message(msg); } } set_event(m_listenerThreadTerminatedEvent);}
Note
The Vivox SDKSampleApp shows the use of a mutex while processing messages (the
HandleMessage()
function). This is a requirement of the SDKSampleApp, not the Vivox SDK. A mutex is only needed if your implementation requires it by design.
Note
Messages can be processed on the same thread as the callback or on a different thread.

Copyright © 2026 Unity Technologies
LegalPrivacy PolicyCookiesDocumentation Terms of UseDo Not Sell or Share My Personal InformationYour Privacy Choices (Cookie Settings)

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S and elsewhere (more info here). Other names or brands are trademarks of their respective owners.

Some pages are machine-translated for convenience, and may contain inaccuracies. In the event of conflicting information, the English version is authoritative.


    Report a problem with this page