Easy Code For Vivox
  • Introduction
    • Official Links
    • Getting Started
      • Wheres The Code
      • Setup EasyCode in My Project
    • Setup Demo Scenes
      • Vivox Developer Portal
      • Unity Gaming Services (UGS) Dashboard
    • Things To Consider
    • FAQ
  • Development Info
    • Design Decisions
    • Release Notes
      • v2.0
      • v1.3
      • v1.2
      • v1.1
      • Template
    • Not Supported
  • Easy Code For Vivox
    • How do I setup EasyCode?
      • Setup Your Credentials
    • How do I do this in EasyCode?
      • Login / Logout
        • Login Properties
        • SetTransmissionMode
        • Login Events
      • Join / Leave Channel
        • Audio Channel
          • Audio Channel Events
        • Text Channel
          • Text Channel Events
        • Channel Events
      • Send Messages
        • Message Events
      • Mute / Unmute
        • Mute / Unmute Events
      • Subscribe to User Events
      • Volume / Audio Settings
        • Audio Device Events
      • Text To Speech ( TTS )
        • TTS Events
    • Vivox Access Tokens
      • Unity Cloud Code
    • Supported Vivox Events
      • Callback Methods
    • Folder Structure / Info
      • / Demo Scenes /
      • / Documentation /
      • / Examples /
      • / Plugins /
      • / Resources /
      • / Scripts /
      • / Settings /
    • Common Errors
  • API Info
    • EasySession.cs
    • EasyManager.cs
      • Main Methods
      • Vivox Event Callbacks
    • Easy3DPositional.cs
    • EasyVivoxUtilities.cs
    • EasySettings.cs
    • Extension Methods
      • EasySIPExtensions.cs
      • GameObjectExtensions.cs
      • TTSMessageExtensions.cs
      • UIExtensions.cs
      • VivoxExtensions.cs
      • EasyDebug.cs
    • EasyEvents.cs
  • Dependency Injection
    • Zenject vs Extenject
    • Install Dependencies
    • Inject Classes
  • Dynamic Events
    • Dynamic Events
    • Tests
    • Gotchas
    • Dynamic Async Events
      • Dont Do
    • Event Examples
  • Related Info
    • How do I do this in Vivox?
      • Conference Chat
    • Pre-Processor Directives
    • How to set iOS Info.plist for Unity?
    • Unity Gaming Services
  • The Future
    • Roadmap
    • Todo / Notes / Changelog
Powered by GitBook
On this page
  • Work In Progress
  • Main methods in EasyManager.cs you will be calling from derived class or referenced using GetComponent<> covered here
  • Login / Logout
  • Join Channel
  • Toggle Voice / Text
  • Send Messages
  • Toggle Mute
  • Volume Adjustment
  • Text To Speech ( TTS )

Was this helpful?

  1. API Info
  2. EasyManager.cs

Main Methods

Work In Progress

Main methods in EasyManager.cs you will be calling from derived class or referenced using GetComponent<> covered here

Another preprocessor directive but this is used by your IDE (Integrated Development Environment) [such as VS Code, VS 2022, Rider] of choice to help separate code functionality in long scripts

 #region Main Vivox Methods For Implementing In UI or call from code

Login / Logout

Logs into Vivox if the username is valid(EasyCode validates username) and no one else currently logged In has the same name, Developer is responsible for checking/implementing this. Takes string username as a parameter. Sets the transmission mode to all so any Voice or Text chat automatically switches to a new channel whenever a channel is joined or switched.

public void LoginToVivox(string userName, bool joinMuted = false)
{
    _login.LoginToVivox(userName, joinMuted);
}

Logout of current Vivox login session.

public void LogoutOfVivox(string userName)
{
    _login.Logout(userName);
}

Updates the current logged in user's frequency for state changes when user is using Audio/Voice channels. If user isn't logged in then set the VivoxParticipantPropertyUpdateFrequency in EasySettings

public void UpdateLoginProperties(string userName, ParticipantPropertyUpdateFrequency updateFrequency)
{
    _login.UpdateLoginProperties(EasySession.LoginSessions[userName], updateFrequency);
}

Join Channel

Development Code

Join an Echo channel. Used mainly to test microphone input and speaker output. Will echo back what you speak in the mic onto your device. Development Code

 public void VivoxJoinChannelEcho(string channelName, bool includeVoice, bool includeText, bool switchToThisChannel)
 {
     if (FilterChannelAndUserName(channelName))
     {
     JoinChannelEcho(channelName, includeVoice, includeText, switchToThisChannel);
     }
 }

Join a Non-Positional channel. Similar to talking on the phone. Development Code

 public void VivoxJoinChannel(string channelName, bool includeVoice, bool includeText, bool switchToThisChannel)
 {
     if (FilterChannelAndUserName(channelName))
     {
         JoinChannel(channelName, includeVoice, includeText, switchToThisChannel);
     }
 }

Join a 3D Positional Channel. This channel is created with the recommended default 3D audio settings. Based on the settings you will only hear voice chat or receive text messages in the channel based on how close you are to other players in the same channel as you. If 2 players are close you can hear each other clearly but the farther you get away from each other the audio will fade out based on the chosen settings. More in Vivox Documentation. Development Code

 public void VivoxJoin3DPositional(string channelName, bool includeVoice, bool includeText, bool switchToThisChannel)
 {
     this.DebugLog($"{mainLoginSession.Presence.Status} {mainLoginSession.Presence.Message}");
     Channel3DProperties channel3DProperties = new Channel3DProperties();
     JoinChannel3DPositional(channelName, includeVoice, includeText, switchToThisChannel, channel3DProperties);
 }

Join a 3D Positional Channel. This channel is created with 3D audio settings based on the parameter inputs you choose. Based on the settings you will only hear voice chat or receive text messages in the channel based on how close you are to other players in the same channel as you. If 2 players are close you can hear each other clearly but the farther you get away from each other the audio will fade out based on the chosen settings. More in Vivox Documentation. Development Code

 public void VivoxJoin3DPositional(string channelName, bool includeVoice, bool includeText, bool switchToThisChannel,
 int maxHearingDistance, int minHearingDistance, float voiceFadeOutOverDistance, AudioFadeModel audioFadeModel)
 {
     this.DebugLog($"{mainLoginSession.Presence.Status} {mainLoginSession.Presence.Message}");
     Channel3DProperties channel3DProperties = new Channel3DProperties(maxHearingDistance, minHearingDistance, voiceFadeOutOverDistance, audioFadeModel);
     JoinChannel3DPositional(channelName, includeVoice, includeText, switchToThisChannel, channel3DProperties);
 }

Production Code

Join a Non-Positional channel. Similar to talking on the phone. Production Code.

public void VivoxJoinChannelProductionNonPositional(string channelName, bool includeVoice, bool includeText, bool switchToThisChannel, bool joinMuted = false)
 {
     if (FilterChannelAndUserName(channelName))
     {
         JoinChannelProduction(channelName, includeVoice, includeText, switchToThisChannel, joinMuted);
     }
 }

Join an Echo channel. Used mainly to test microphone input and speaker output. Will echo back what you speak in the mic onto your device. Production Code

 public void VivoxJoinChannelProductionEcho(string channelName, bool includeVoice, bool includeText, bool switchToThisChannel, bool joinMuted = false)
 {
     if (FilterChannelAndUserName(channelName))
     {
         JoinChannelProductionEcho(channelName, includeVoice, includeText, switchToThisChannel, joinMuted);
     }
 }

Join a 3D Positional Channel. This channel is created with 3D audio settings. Based on the settings you will only hear voice chat or receive text messages in the channel based on how close you are to other players in the same channel as you. If 2 players are close you can hear each other clearly but the farther you get away from each other the audio will fade out based on the chosen settings. More in Vivox Documentation. Production Code

 public void VivoxJoinChannelProduction3DPositional(string channelName, bool includeVoice, bool includeText, bool switchToThisChannel,
 Channel3DProperties channel3DProperties = null, bool joinMuted = false)
 {
     if (FilterChannelAndUserName(channelName))
     {
         JoinChannelProduction3DPositional(channelName, includeVoice, includeText, switchToThisChannel, channel3DProperties, joinMuted);
     }
 }

Join a 3D Positional Channel. This channel is created with 3D audio settings. Based on the settings you will only hear voice chat or receive text messages in the channel based on how close you are to other players in the same channel as you. If 2 players are close you can hear each other clearly but the farther you get away from each other the audio will fade out based on the chosen settings.

  • This Method is designed for MMO games where you will have different players in different regions. To have all the players in a region on the same server/shard the region parameter will add the region name to the player SIP address. Recommended to hash the channel name for all players in the channel.

  • You must use the private bool FilterChannelAndUserName(string nameToFilter) to filter the channel name before hashing. This method doesn't do it for you in the event your channel name is hashed

  • You can also add a squad name to better keep track of all the channels in the Vivox server/shard. Can be null

  • Region and squad name are appeneded to the channel name in this format $"{region}.{channelNameOrHash}.{squadName}";

    or

    $"region.channelName.squad1";

    If region or squad name is null then use this format

    $"channelNameOrHash.squadName";

    or

    $"region.channelNameOrHash";

More in Vivox Documentation. Production Code

 public void VivoxJoinChannelProduction3DPositionalMMO(bool includeVoice, bool includeText, bool switchToThisChannel,
 string region, string channelNameOrHash, string squadName, Channel3DProperties channel3DProperties = null, bool joinMuted = false)
 {
 if (FilterChannelAndUserName(channelNameOrHash))
 {
 JoinChannelProduction3DPositionalMMO(includeVoice, includeText, switchToThisChannel, region, channelNameOrHash, squadName, channel3DProperties, joinMuted);
 }
 }

Leave a channel by providing the channel name. If using the MMO method public void VivoxJoinChannelProduction3DPositionalMMO() then you should pass channel name should be in this format

 public void VivoxLeaveChannel(string channelname)
 {
     LeaveChannel(channelname);
 }

Toggle Voice / Text

Toggle Voice Chat on or off in a channel. Must be connected to a channel or you will receive an error

 public void VivoxToggleVoiceInChannel(string channelName, bool toggleOn)
 {
     SetVoiceActiveInChannel(channelName, toggleOn);
 }

Toggle Text Chat on or off in a channel. Must be connected to a channel or you will receive an error

 public void VivoxToggleTextInChannel(string channelName, bool toggleOn)
 {
     SetTextActiveInChannel(channelName, toggleOn);
 }

Send Messages

Send messages in a Text Channel. Must be connected to an active Text channel. Provide channel name and message. You can also provide secret messages that only the developer can see unless you wish your players to see these messages. In the Vivox Documentation this is referred to as applicationStanzaNamespace and applicationStanzaBody

 public void VivoxSendChannelMessage(string channelName, string msg, string commandNameSpace = null, string commandBody = null)
 {
     SendChannelMessage(channelName, msg, commandNameSpace, commandBody);
 }

Send direct messages to a logged in user. Both players must be connected to Vivox servers or the message will fail. Provide user name of player to send message to and message. You can also provide secret messages that only the developer can see unless you wish your players to see these messages. In the Vivox Documentation this is referred to as applicationStanzaNamespace and applicationStanzaBody

 public void VivoxSendDirectMessage(string userToMsg, string msg, string commandNameSpace = null, string commandBody = null)
 {
     SendDirectMessage(userToMsg, msg, commandNameSpace, commandBody);
 }

Toggle Mute

Toggle the local players audio on or off. This will stop Vivox from transmitting any audio to any channels the user is connected to.

 public void VivoxToggleMuteSelf(bool mute)
 {
     ToggleMuteSelf(mute);
 }

Toggle any remote players audio on or off. This will block any audio that the muted player is speaking in the channel in which they were blocked. Only mutes them for the local user, not everyone in the channel.

 public void VivoxToggleMuteUser(string userName, string channelName)
 {
     ToggleMuteRemoteUser(userName, channelName);
 }

Volume Adjustment

Adjust the Voice volume of local player/user on the machine

 public void VivoxAdjustLocalUserVoiceVolume(int volume)
 {
     AdjustLocalUserVolume(volume);
 }

Adjust the Voice volume of remote players/users

 public void VivoxAdjustRemoteUserVolume(string userName, string channelName, float volume)
 {
     AdjustRemoteUserVolume(userName, channelName, volume);
 }

Text To Speech ( TTS )

Speak any text locally [TTS = Text-To-Speech] Will not send over the Vivox network

 public void VivoxTTSSpeakMsgLocal(string msgToSpeak)
 {
     SpeakTTS(msgToSpeak);
 }

Speak any text locally, remotely, or both with options to Queue messages or override old messages when a new message is played. TTSDestination will give you the options to play TTS accordingly

 public void VivoxTTSSpeakMsg(string msgToSpeak, TTSDestination playMode)
 {
     SpeakTTS(msgToSpeak, playMode);
 }

This method allows you to choose male or female voice

(**If your a Christian the male voice doesn’t pronounce Jesus’s name correctly so I recommend using the female voice or you can provide your players with the option to choose)

 public void VivoxChooseTTSVoiceGender(VoiceGender voiceGender)
 {
     ChooseVoiceGender(voiceGender);
 }
End of the #If region explained in the beginning of this documentation
 #endregion

PreviousEasyManager.csNextVivox Event Callbacks

Last updated 2 years ago

Was this helpful?