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 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
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.
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
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
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
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
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
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);
}
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