For the complete documentation index, see llms.txt. This page is also available as Markdown.

EasyManager.cs

EasyManager inherits from MonoBehaviour so it can be attached to a GameObject and inherited to make your own Custom VivoxManager. EasyManager is basically a super class/wrapper for all EasyCode functionality. Instead of using EasyManager you can access EasyCode functionality directly/separately by injecting necessary classes in your script by using the [Inject] attribute. Read more about it here

Necessary libraries for EasyManager.cs to work. namespace separate's your project or script from other peoples scripts or libraries that use similar names to avoid compile errors. It also forces people to use a using statement when they want to use your script or library

using EasyCodeForVivox.Events;
using EasyCodeForVivox.Utilities;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
using VivoxUnity;
using Zenject;

namespace EasyCodeForVivox
{

Private variables that are set by the Initialize() method.

    private EasyLogin _login;
    private EasyChannel _channel;
    private EasyAudioChannel _voiceChannel;
    private EasyTextChannel _textChannel;
    private EasyUsers _users;
    private EasyMessages _messages;
    private EasyMute _mute;
    private EasyTextToSpeech _textToSpeech;
    private EasyAudio _audio;
    private EasySettingsSO _settings;
    private EasyEvents _events;

Intialize() method is used to Inject and assign the private variables to any classes EasyManager needs to function. Instances are injected by Zenject dependency injection by using the [Inject] attribute

I have tried to break up bigger methods and explain them in better detail. By clicking the tabs or exapandles you will see more info reated to what each method is doing

InitializeClient() is used to initialize Vivox Client, register Dynamic Events, and subscribe to necessary events for EasyCode to work.

A Pre-Processor Directive is used to disable logging for builds for faster performance. Read more about it here

Checks if Vivox Client is Initialized, if not it Initializes it then sets I

Subscribes to necessary Vivox events for EasyManager to work properly

Checks if Dynamic Events have been enabled (on be default). You can change this in Assets/EasyCodeForVivox/Settings/EasySettings scriptable object. Read more about Dynamic Events here. I have left this comment in to remind myself why I am using List<Task> vs Parallel.ForEach vs a single Task

UnitializeClient() is used to clean up resources used by Vivox and EasyCode. Also used to subscribe from events to prevent memory leaks

Subscribe To Vivox Events

SubscribeToVivoxEvents(); Subscribes to relevant Vivox events .

Audio Device Events

Use EasySession.cs to access VivoxClient (Client) and its Audio Device events

AvailableDevices.AfterKeyAdded

Called when a new Audio device is detected

AvailableDevices.BeforeKeyRemoved

Called when an Audio device is removed

AvailableDevices.AfterValueUpdated

Called after the 2 previous events and is called when a device is added, removed, or changed

OnAudioInputDeviceAdded

requires (object sender, KeyEventArg keyArgs)

OnAudioInputDeviceRemoved

requires (object sender, KeyEventArg keyArgs)

OnAudioInputDeviceUpdated

requires (object sender, ValueEventArg<string, IAudioDevice> valueArgs)

OnAudioOutputDeviceAdded

requires (object sender, KeyEventArg keyArgs)

OnAudioOutputDeviceRemoved

requires (object sender, KeyEventArg keyArgs)

OnAudioOutputDeviceUpdated

requires (object sender, ValueEventArg<string, IAudioDevice> valueArgs)

Subscribe to Audio Device events if you want to allow users to change their Mic / Headphone / Speaker device settings in game instead of having to exit the game and adjust audio device settings

Login Events

Uses EasyEvents.cs to access Login events

You can also access EasyEvents by injecting it into your class using Zenject dependency injection. Read more about it here.

Event

Purpose

LoggingIn

Called when Vivox begins logging in a user

LoggedIn

Called when Vivox successfully logs in a user

LoggingOut

Called locally and immediately when the LogoutOfVivox() method is called

LoggedOut

Called locally and fires after the LogoutOfVivox() method is called

LoginAdded

Called when a new LoginSession is added to Vivox Client - User Logged In

LoginRemoved

Called when a new LoginSession is removed to Vivox Client - User Logged out

LoginUpdated

Called when a new LoginSession values are updated in Vivox Client - User Changed Name

Callback Method

Parameters

OnLoggingIn

requires (ILoginSession loginSession)

OnLoggedIn

requires (ILoginSession loginSession)

OnLoggedInSetup

requires (ILoginSession loginSession)

OnLoggingOut

requires (ILoginSession loginSession)

OnLoggedOut

requires (ILoginSession loginSession)

OnLoginAdded

requires (AccountId accountId)

OnLoginRemoved

requires (AccountId accountId)

OnLoginUpdated

requires (ILoginSession loginSession)

Subscribe to Login events if you want to perform actions based on each level of logging in or out, you want to offer users the ability to have multiple login sessions at 1 time and keep track of them, or simply want to implement a Debug.Log statement to ensure the player is logged in successfully.

Channel Events

Uses EasyEvents.cs to access Channel events

You can also access EasyEvents by injecting it into your class using Zenject dependency injection. Read more about it here.

Event

Purpose

ChannelConnecting

Called when Vivox starts connecting a user to a channel. If the channel doesn't exists one is created

ChannelConnected

Called when Vivox successfully connects a user to a channel.

ChannelDisconnecting

Called when Vivox starts disconnecting a user from a channel.

ChannelDisconnected

Called when Vivox successfully disconnects a user from a channel.

Callback Method

Parameters

OnChannelConnecting

requires (IChannelSession channelSession)

OnChannelConnected

requires (IChannelSession channelSession)

OnChannelDisconnecting

requires (IChannelSession channelSession)

OnChannelDisconnected

requires (IChannelSession channelSession)

Subscribe to Channel events if you want to perform actions based on each level of connecting/disconnecting or simply want to implement a Debug.Log statement to ensure the player is connected to a channel

Audio Channel Events

Uses EasyEvents.cs to access Audio Channel events

You can also access EasyEvents by injecting it into your class using Zenject dependency injection. Read more about it here.

Event

Purpose

VoiceChannelConnecting

Called when Vivox starts connecting a user to a voice channel. Channel must exist for voice to connect

VoiceChannelConnected

Called when Vivox successfully connects a user to voice a channel.

VoiceChannelDisconnecting

Called when Vivox starts disconnecting a user from a voice channel.

VoiceChannelDisconnected

Called when Vivox successfully disconnects a user from a voice channel.

Callback Method

Parameters

OnVoiceConnecting

requires (IChannelSession channelSession)

OnVoiceConnected

requires (IChannelSession channelSession)

OnVoiceDisconnecting

requires (IChannelSession channelSession)

OnVoiceDisconnected

requires (IChannelSession channelSession)

Subscribe to Voice Channel events if you want to perform actions based on each level of connecting/disconnecting or simply want to implement a Debug.Log statement to ensure the player is connected to a voice channel

Text Channel Events

Uses EasyEvents.cs to access Text Channel events

You can also access EasyEvents by injecting it into your class using Zenject dependency injection. Read more about it here.

Event

Purpose

TextChannelConnecting

Called when Vivox starts connecting a user to a channel. Channel must exist for text to connect

TextChannelConnected

Called when Vivox successfully connects a user to a text channel.

TextChannelDisconnecting

Called when Vivox starts disconnecting a user from a text channel.

TextChannelDisconnected

Called when Vivox successfully disconnects a user from a text channel.

Callback Method

Parameters

OnTextChannelConnecting

requires (IChannelSession channelSession)

OnTextChannelConnected

requires (IChannelSession channelSession)

OnTextChannelDisconnecting

requires (IChannelSession channelSession)

OnTextChannelDisconnected

requires (IChannelSession channelSession)

Subscribe to Text Channel events if you want to perform actions based on each level of connecting/disconnecting or simply want to implement a Debug.Log statement to ensure the player is connected to a text channel

Message Events

Uses EasyEvents.cs to access Channel and Direct message events

You can also access EasyEvents by injecting it into your class using Zenject dependency injection. Read more about it here.

Event

Purpose

ChannelMessageRecieved

Called when a channel message is received. The message is passed to the method parameter

EventMessageRecieved

Called when a channel event/hidden message is received. The message is passed to the method parameter

DirectMessageRecieved

Called when a direct message is received. The message is passed to the method parameter

DirectMessageFailed

Called when a message has failed to send. The message is passed to the method parameter

Callback Methods

Parameters

OnChannelMessageRecieved

requires (IChannelTextMessage textMessage)

OnEventMessageRecieved

requires (IChannelTextMessage textMessage)

OnDirectMessageRecieved

requires (IDirectedTextMessage directedTextMessage)

OnDirectMessageFailed

requires (IFailedDirectedTextMessage failedMessage)

These Message events are necessary to receive channel, event/hidden, or direct messages. Event/Hidden messages can be used if you (very useful if you are not using a Networking Stack) want to pass info to players in the channel. When a message fails to send you can use the OnDirectMessageFailed callback to store the message or try and resend it.

User Events

The keywords Fire and Called are used interchangeably

Uses EasyEvents.cs to access User events

You can also access EasyEvents by injecting it into your class using Zenject dependency injection. Read more about it here.

Event

Purpose

UserJoinedChannel

Called when a user joins a channel. This event will fire for every user that is in the same channel

UserLeftChannel

Called when a user leaves a channel. This event will fire for every user that is in the same channel

UserValuesUpdated

Called when a user values are updated in a channel such as speaking, muted, name change. This event will fire for every user that is in the same channel. This event is called many times by Vivox implement at your own peril 😬 . You can set

Callback Methods

Parameters

OnParticipantAdded

requires (IParticipant participant)

OnParticipantRemoved

requires (IParticipant participant)

OnParticipantValueUpdated

requires (IParticipant participant)

If you want to know if a user has joined or left a channel

Uses EasyEvents.cs to access User events

You can also access EasyEvents by injecting it into your class using Zenject dependency injection. Read more about it here.

Event

Purpose

UserMuted

Called when a user is muted

UserUnmuted

Called when a user is unmuted

UserSpeaking

Called when a user is speaking

UserNotSpeaking

Called when a user is no longer speaking

Callback Method

Parameters

OnUserMuted

requires (IParticipant participant)

OnUserUnmuted

requires (IParticipant participant)

OnUserSpeaking

requires (IParticipant participant)

OnUserNotSpeaking

requires (IParticipant participant)

If you want to know if a player is speaking or muted to update your UI with a different image for each event.

Text To Speech ( TTS ) Events

Uses EasyEvents.cs to access Text-To-Speech events

You can also access EasyEvents by injecting it into your class using Zenject dependency injection. Read more about it here.

Event

Purpose

TTSMessageAdded

Called when a message is spoken or added to the TTS queue.

TTSMessageRemoved

Called when a message is removed from the TTS queue.

TTSMessageUpdated

Called when a message is spoken, overridden, removed, added to the TTS queue or TTS voice changed

OnTTSMessageAdded

requires (ITTSMessageQueueEventArgs ttsArgs)

OnTTSMessageRemoved

requires (ITTSMessageQueueEventArgs ttsArgs)

OnTTSMessageUpdated

requires (ITTSMessageQueueEventArgs ttsArgs)

If you want to keep a log of all messages sent thru TTS for accessibility reasons or send notifications to the user using TTS when their message is done playing or wants to send message after hearing it first

Unsubscribe From Vivox Events

UnsubscribeToVivoxEvents() unsubscribes from all the events explained above. Refer to explanations above for each category. This is called on OnApplicationQuit() in Unity

Last updated