Callback Methods
Work In Progress
Only Applies if Inheriting from EasyManager.cs
Callback Methods can be Overridden
All base.
Methods can be deleted. Most are just Debug.Log
statements to describe the current Vivox events. You may see some of these callback methods are empty. This is because it was not necessary to add logic to these callbacks since this is merely an example. You may or may not want to use all the callbacks available depending on your application needs.
Login Callbacks
Gets called when local user in the process of logging in
public override void OnLoggingIn(ILoginSession loginSession)
{
base.OnLoggingIn(loginSession);
}
Gets called when a local user is logged in successfully. If you want to immediately join a channel after being logged in wait 0.5f - 1f second before logging in or you may get an error.
public override void OnLoggedIn(ILoginSession loginSession)
{
base.OnLoggedIn(loginSession);
messageText.text += $"\nLogged In as {loginSession.LoginSessionId.DisplayName}";
}
Vivox does not call this method. This is a local implementation. Recommended to clean up player/user resources no longer needed in this callback.
Gets called when local user in the process of logging out
public override void OnLoggingOut(ILoginSession loginSession)
{
base.OnLoggingOut(loginSession);
}
Vivox does not call this method. This is a local implementation recommended to clean up player/user resources.
Gets called when local user is logged out
public override void OnLoggedOut(ILoginSession loginSession)
{
base.OnLoggedOut(loginSession);
messageText.text += $"\nLogged out {loginSession.LoginSessionId.DisplayName}";
this.DebugLog("Logged Out");
}
Channel Callbacks
Channel Callbacks
This is called when a channel begins connecting
public override void OnChannelConnecting(IChannelSession channelSession)
{
base.OnChannelConnecting(channelSession);
}
This is called when a channel is connected
public override void OnChannelConnected(IChannelSession channelSession)
{
base.OnChannelConnected(channelSession);
messageText.text += $"\nChannel {channelSession.Channel.Name} has connected : {channelSession.Channel.Type}";
}
This is called when a channel begins disconnecting
public override void OnChannelDisconnecting(IChannelSession channelSession)
{
base.OnChannelDisconnecting(channelSession);
}
This is called when a channel is disconnected
public override void OnChannelDisconnected(IChannelSession channelSession)
{
base.OnChannelDisconnected(channelSession);
messageText.text += $"\nChannel {channelSession.Channel.Name} has disconnected : {channelSession.Channel.Type}";
}
Voice Channel Callbacks
This is called when a voice channel begins connecting
public override void OnVoiceConnecting(IChannelSession channelSession)
{
base.OnVoiceConnecting(channelSession);
}
This is called when a voice channel is connected
public override void OnVoiceConnected(IChannelSession channelSession)
{
base.OnVoiceConnected(channelSession);
messageText.text += $"\nVoice Channel {channelSession.Channel.Name} has connected : {channelSession.Channel.Type}";
}
This is called when a voice channel begins disconnecting
public override void OnVoiceDisconnecting(IChannelSession channelSession)
{
base.OnVoiceDisconnecting(channelSession);
}
This is called when a voice channel is disconnected
public override void OnVoiceDisconnected(IChannelSession channelSession)
{
base.OnVoiceDisconnected(channelSession);
messageText.text += $"\nVoice Channel {channelSession.Channel.Name} has disconnected : {channelSession.Channel.Type}";
}
Text Channel Callbacks
This is called when a text channel begins connecting
public override void OnTextChannelConnecting(IChannelSession channelSession)
{
base.OnTextChannelConnecting(channelSession);
}
This is called when a text channel is connected
public override void OnTextChannelConnected(IChannelSession channelSession)
{
base.OnTextChannelConnected(channelSession);
messageText.text += $"\nTextChannel {channelSession.Channel.Name} has connected : {channelSession.Channel.Type}";
}
This is called when a text channel begins disconnecting
public override void OnTextChannelDisconnecting(IChannelSession channelSession)
{
base.OnTextChannelDisconnecting(channelSession);
}
This is called when a text channel is disconnected
public override void OnTextChannelDisconnected(IChannelSession channelSession)
{
base.OnTextChannelDisconnected(channelSession);
messageText.text += $"\nText Channel {channelSession.Channel.Name} has connected : {channelSession.Channel.Type}";
}
User Callbacks
The keywords User and Participant are used interchangeably
This called when a user joins a channel
public override void OnUserJoinedChannel(IParticipant participant)
{
base.OnParticipantAdded(participant);
messageText.text += $"\n{participant.Account.DisplayName} has joined {participant.ParentChannelSession.Channel.Name}";
}
This is called when a user leaves a channel
public override void OnUserLeftChannel(IParticipant participant)
{
base.OnParticipantRemoved(participant);
messageText.text += $"\n{participant.Account.DisplayName} has left {participant.ParentChannelSession.Channel.Name}";
}
This is called whenever a user speaks, stops speaking, name changes, is muted, is unmuted. It is called quite often by Vivox so implement at your own peril.
public override void OnUserValuesUpdated(IParticipant participant)
{
base.OnParticipantValueUpdated(participant);
}
This is called when a user is muted
public override void OnUserMuted(IParticipant participant)
{
base.OnUserMuted(participant);
messageText.text += $"\n{participant.Account.DisplayName} has been muted";
}
This is called when a user is unmuted
public override void OnUserUnmuted(IParticipant participant)
{
base.OnUserUnmuted(participant);
messageText.text += $"\n{participant.Account.DisplayName} has been unmuted";
}
This is called when a user is speaking.
public override void OnUserSpeaking(IParticipant participant)
{
base.OnUserSpeaking(participant);
messageText.text += $"\n{participant.Account.DisplayName} is speaking";
}
This is called when a user stops speaking
public override void OnUserNotSpeaking(IParticipant participant)
{
base.OnUserNotSpeaking(participant);
messageText.text += $"\n{participant.Account.DisplayName} is not speaking";
}
Message Callbacks
This is called when a message is received. Everyone in the same channel will have this event fired
public override void OnChannelMessageRecieved( IChannelTextMessage textMessage)
{
base.OnChannelMessageRecieved(textMessage);
messageText.text += $"\n{textMessage.ReceivedTime} : From {textMessage.Sender.DisplayName} : {textMessage.Message}";
}
This is called when a direct message is received
public override void OnDirectMessageRecieved(IDirectedTextMessage directedTextMessage)
{
base.OnDirectMessageRecieved(directedTextMessage);
messageText.text += $"\n{directedTextMessage.ReceivedTime} : From {directedTextMessage.Sender.DisplayName} : {directedTextMessage.Message}";
}
This is called when a direct message fails to send, due to network issues or the user isn't logged in at the time
public override void OnDirectMessageFailed(IFailedDirectedTextMessage failedMessage)
{
base.OnDirectMessageFailed(failedMessage);
messageText.text += $"\nMessage failed from {failedMessage.Sender.DisplayName} : RequestID - {failedMessage.RequestId} : Status Code - {failedMessage.StatusCode}";
}
Text To Speech Callbacks
This is called when a Text To Speech message is playing or added to the queue
public override void OnTTSMessageAdded(ITTSMessageQueueEventArgs ttsArgs)
{
base.OnTTSMessageAdded(ttsArgs);
messageText.text += $"\nTTS message added : Destination - {ttsArgs.Message.Destination} : Number Of Consumers - {ttsArgs.Message.NumConsumers} : Duration - {ttsArgs.Message.Duration} : State - {ttsArgs.Message.State} : Voice - {ttsArgs.Message.Voice} : TTS Message - {ttsArgs.Message.Text}";
}
This is called when a Text To Speech message is done playing
public override void OnTTSMessageRemoved(ITTSMessageQueueEventArgs ttsArgs)
{
base.OnTTSMessageRemoved(ttsArgs);
messageText.text += $"\nTTS message removed : Destination - {ttsArgs.Message.Destination} : Number Of Consumers - {ttsArgs.Message.NumConsumers} : Duration - {ttsArgs.Message.Duration} : State - {ttsArgs.Message.State} : Voice - {ttsArgs.Message.Voice} : TTS Message - {ttsArgs.Message.Text}";
}
This is called when a Text To Speech message is updated while playing, etc… Gets called very often when using Text To Speech. Implement at your own peril
public override void OnTTSMessageUpdated(ITTSMessageQueueEventArgs ttsArgs)
{
base.OnTTSMessageUpdated(ttsArgs);
messageText.text += $"\nTTS message updated : Destination - {ttsArgs.Message.Destination} : Number Of Consumers - {ttsArgs.Message.NumConsumers} : Duration - {ttsArgs.Message.Duration} : State - {ttsArgs.Message.State} : Voice - {ttsArgs.Message.Voice} : TTS Message - {ttsArgs.Message.Text}";
}
Last updated