Purpose
This article details recommended best practices for when to sign in and sign out of the Vivox service. It discusses the tangible benefits and trade offs of staying signed in throughout a play session, as well as rare cases where it makes sense to sign out early.
Table of Contents
- High level recommendations for signing in and out
- What are the primary benefits to staying signed in?
- What are the trade offs to staying signed in?
- Are there scenarios where signing out makes sense?
High level recommendations for signing in and out
Our recommended best practice is to sign in to Vivox soon after initializing Vivox when the application is first launched/loaded, and to stay signed in until quitting the application. We recommend signing out on purpose only in a few exceptional circumstances covered in this section.
In most cases, you should only need to sign in once, unless a login failure requires a retry or Vivox is unable to recover automatically from a prolonged network interruption, resulting in an unexpected logout.
Example game flow with key events
The image below illustrates a typical game flow for a "Lobby to Match" style integration. For instance, in a squad-based shooter, MOBA, battle royale, or similar game mode, you might party up in advance with a few friends, then be put into a series of matches with other players. In this case you might first join a NonPositional Lobby channel, then switch between different Positional or NonPositional channels for each Match.
There are many similar variations depending on your use case, but this is a great place to start thinking about the architecture of your integration.
What are the primary benefits to staying signed in?
In short, staying signed in for the entire gameplay session allows quicker and more stable voice chat, and supports a number of passive features.
Avoid Unnecessary Delays
Staying signed in to Vivox streamlines your voice chat experience and eliminates avoidable delays. Here’s how signing out and back in can impact performance:
-
(Relatively) Time Consuming Login Process:
When you sign in after signing out, several steps need to happen:- Waiting for an event to signal the sign out is entirely finished before signing back in.
- Network round trip to fetch a Vivox access token from your game server to the client (when not using the Unity Authentication Service (UAS) for authentication).
- Network round trip from the client to transmit and processes the login request on the Vivox server.
- Triggering necessary events back on your game client, finally signalling it is safe to join a channel.
Though usually fairly quick, this whole process can take up to several seconds depending on the game client's distance from both your game server and the Vivox login server.
-
Loading Blocked User Data:
Every time you sign in, the local user's full list of blocked users must be loaded before you can safely join voice or text channels. Loading the user's initial block list data is only necessary once per login session but adds further delay if you sign out unnecessarily. This process is normally quick, but the amount of time needed depends on the size of the block list, with very large lists requiring more time. -
Channel Switching Delays:
It is tempting to assume that when a user leaves their last channel, they're "done" with voice chat for now and it's safe to sign out. If your implementation only requires one Vivox channel, it becomes critical for your code to recognize cases where a user is simply switching from one channel to another. Code which naively signs out—or worse, disconnects or uninitializes Vivox—whenever you leave the last active channel is inefficient and can lead to unnecessary delays and potential issues when you expect to connect to a new channel soon after. This can create a frustrating user experience, especially if you routinely go from 1 to 0 to 1 channel again quickly.
Avoid Stability Issues
Staying signed into Vivox throughout an entire play session reduces the risk of intermittent issues resulting from improper state management or timing of SDK calls. This is especially true in cases where a poorly coded channel switch flow involves a log out, resulting in Vivox rapidly signing out and back in the same user when leaving and rejoining channels quickly. If the proper sequencing and timing of these calls isn't followed by waiting for and handling events properly, issues can arise which are often difficult to diagnose or catch in testing.
Support Passive Features
Staying signed into Vivox also unlocks additional conveniences that enhance the overall gameplay experience—even when you're not actively chatting.
-
Seamless Text Messaging:
Staying signed in allows you to send and receive direct messages (DMs) even when you're not actively connected to a voice chat channel. This is especially useful for coordinating with teammates before or between channel connections. -
Simplified Mic and Audio Checks:
Many games allow the user to join anEcho
type channel in the voice settings menu for testing audio input and output device selection and volume. Staying signed in ensures you can access this feature anytime, making it quick and easy to verify your audio setup without delays.
What are the trade offs to staying signed in?
Resource Use While Signed In to Vivox
While signed into Vivox, the Vivox library uses minimal device resources to maintain and monitor the connection.
-
Minimal Bandwidth:
To maintain an active TCP connection to Vivox servers, the Vivox library sends and receives a ping packet every 90 seconds. -
Thread Count:
The first time a user signs into Vivox, the Vivox library creates two new threads used to monitor network reachability so Vivox can recover quickly in the event of network loss. Signing in additional Vivox users beyond the first does not create additional threads.
Important: these two threads persist after the first login until the Vivox library is completely uninitialized. While this technically makes them a resource cost for signing in, signing out of Vivox without also uninitializing will not destroy these two threads.
Will signing out more frequently save me money?
Not always, and less often than you might assume.
Understanding Vivox pricing
The Vivox standard pricing agreement does not charge per individual signed in user, it only counts blocks of 5000 users signed in at the same time. For instance, when the highest count of users signed into Vivox in a month is anywhere in the range 5001 to 10000, the cost is the same. Additionally, standard pricing is based on only the single highest player count measured per month—aside from that one moment, the number of players signed in the rest of the month has no impact on cost. See the Vivox: Pricing and Billing FAQ for details.
Why staying signed in during core gameplay makes sense
If your game includes voice or text chat as a major feature of play, then almost all the time user is actually playing the game—that is, in the core gameplay loop—they will need to be signed in to communicate with others.
An example setup might have a user switching between a 5 minute lobby channel and 15 minute match channel. Signing out for only a few seconds between channel joins during these transition points will mean the user is signed in about 99.5% of the time while playing in this mode, until they back all the way out to a main menu. In aggregate, signing out like this might lower your average Peak Concurrent User measurement by 0.5%, but unless this drops your PCU below a 5000 user break point, this won't affect your cost to use Vivox.
What about before and after the core gameplay loop?
We expect that for most multiplayer games using voice or text chat, a very high percentage of signed in players will also be connected to an active voice or text session most of the time while the app is open. Of course, there might be a short period after the app launches where the player doesn't need communication features yet, such as sitting at a title screen, selecting a character, choosing a game mode, and so on.
So long as you're not interested in the passive features that being signed into Vivox supports and don't mind a delay before the first channel join, it's fine to wait to sign in until the first time the player starts a gameplay mode where they'll use voice or text. It might also be true that not every mode of play uses Vivox. If your game features a solo training mode for instance, it's fine to sign out from Vivox while using it.
The main point of this "best practice" is to consider when the player has first entered the part of the experience where they're expected to be actively communicating with others the majority of the time, and to remain signed in from this point.
Are there scenarios where signing out makes sense?
There are two situations where signing out early (before application exit) makes sense:
-
Actually Switching Users:
Some games feature an account login screen allowing users to sign in from within the app itself, rather than from a game launcher or console profile beforehand. If your game allows users to switch profiles within the app, ensure they are signed out of Vivox when switching accounts. Wait to sign in the new user—or indeed the initial user—into Vivox only after their game profile is selected and signed in. -
Changing the User's Display Name:
Vivox "accounts" are not persistent, meaning user information and settings only exist while signed in. Due to this temporary nature, the Vivox SDK doesn't support changing a user's display name while signed in. To update the display name used by Vivox, users must sign out and set a new name when signing back in.