Skip to main content

VivoxManager

A class in Root.Township, Alta.Voice.

Client singleton that logs in to Vivox voice chat with the player's Alta account and joins a positional voice channel for the current server. Disabled on headless servers.

Constructors​

MemberWhat it is
VivoxManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

4 private and internal fields
MemberWhat it is
private static readonly Logger loggerNLog logger for this class.
private const int MaxLoginRetryCountConstant 5. The retry loop uses its own literal instead.
private VivoxChannel serverChannelThe Vivox channel for the current server, or null.
private VivoxVoice voiceThe active Vivox voice object from the joined channel.

Properties​

MemberWhat it is
VivoxClient Client { get; private set; }The Vivox client. Null on headless servers and after termination.
LoginState ManagerState { get; private set; }Login state of the manager: logged out, logging in or logged in.

Events​

MemberWhat it is
static event Action<VivoxClient> ClientCreatedRaised once the Vivox client is created in Awake.

Methods​

MemberWhat it is
async Task LoginVivoxClient()Logs in to Vivox with the Alta user ID and name, retrying up to 4 times with a growing delay. Skips if already logged in or logging in.
void OnAltaAccountLogin()Alta login handler; starts the Vivox login.
protected override void Awake()On clients, hooks game mode and Alta login events, creates the VivoxClient and raises ClientCreated. On headless servers it disables itself.
18 private and internal methods
MemberWhat it is
private void CloseVivoxClient()Deactivates the voice and leaves the server channel. Does not log out.
private void OnAltaAccountLogout()Logs out of Vivox and stops listening for the local player.
private void OnApplicationQuit()Leaves the channel and terminates the client.
private void OnDestroy()Leaves the channel and terminates the client.
private void OnGameModeChanged()When the game mode is cleared, logs out of Vivox and logs back in.
private void OnGameReload()Closes the voice channel when the game reloads.
private void OnLocalPlayerSet(IPlayer player)Sets up voice for the new local player.
private void OnPlayerControllerDestroyed(NetworkEntity entity, bool isUnload)Deactivates the voice when the player's controller is destroyed.
private void OnPlayerControllerSet(IPlayer player, PlayerController playerController)Activates voice on the controller's head, except for the customization controller.
private void OnPlayerDestroyedByScene(NetworkEntity entity, bool isUnload)Closes the voice channel when the local player is destroyed.
private void OnPlayerJoinedServer(Player newPlayer)Once 2 or more players are on the server, unhooks itself and sets up voice for the local player. Not hooked anywhere in this class.
private void OnVivoxClientLogin()After Vivox login, listens for the local player and sets up voice if one already exists.
private VivoxChannel SetupChannelForServer()Leaves any current channel and makes a voice-only positional channel named after the joined server.
private async void SetupPlayer(IPlayer player)Joins the server channel for the player and hooks player destroy and game reload.
private void SetVoice(VivoxVoice voice)Stores the voice object from the joined channel and activates it on the local player's controller.
private void TerminateChannel()Leaves the server channel if one is joined.
private void TerminateClient()Terminates the Vivox client and clears Client.
private void Update()Ticks the Vivox client each frame.