Text Channel Events
Inherit from EasyManager.cs
using EasyCodeForVivox;
public class VivoxManager : EasyManager
{
}
Inject EasyEvents
using EasyCodeForVivox.Events;
using UnityEngine;
using Zenject;
public class VivoxEvents : MonoBehaviour
{
EasyEvents _events;
[Inject]
private void Initialize(EasyEvents events)
{
_events = events;
}
}
Dynamic Events
Make sure Dynamic Events are enabled

How to Subscribe to Text Channel Events in EasyCode
EasyManager
// Text Channels Event Callbacks
protected override void OnTextChannelConnecting(IChannelSession channelSession)
{
base.OnTextChannelConnecting(channelSession);
}
protected override void OnTextChannelConnected(IChannelSession channelSession)
{
base.OnTextChannelConnected(channelSession);
}
protected override void OnTextChannelDisconnecting(IChannelSession channelSession)
{
base.OnTextChannelDisconnecting(channelSession);
}
protected override void OnTextChannelDisconnected(IChannelSession channelSession)
{
base.OnTextChannelDisconnected(channelSession);
}
EasyEvents
public void SubscribeToTextChannelEvents()
{
_events.TextChannelConnecting += OnTextChannelConnecting;
_events.TextChannelConnected += OnTextChannelConnected;
_events.TextChannelDisconnecting += OnTextChannelDisconnecting;
_events.TextChannelDisconnected += OnTextChannelDisconnected;
}
public void UnsubscribeToTextChannelEvents()
{
_events.TextChannelConnecting -= OnTextChannelConnecting;
_events.TextChannelConnected -= OnTextChannelConnected;
_events.TextChannelDisconnecting -= OnTextChannelDisconnecting;
_events.TextChannelDisconnected -= OnTextChannelDisconnected;
}
protected virtual void OnTextChannelConnecting(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Text Is Connecting In Channel");
}
protected virtual void OnTextChannelConnected(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Text Has Connected In Channel");
}
protected virtual void OnTextChannelDisconnecting(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Text Is Disconnecting In Channel");
}
protected virtual void OnTextChannelDisconnected(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Text Has Disconnected In Channel");
}
Dynamic Events
Make sure the parameter in your method matches the event type. See what parameter is required for each AudioChannel Event here. Dynamic events will dynamically invoke your method at runtime on every game object that has a dynamic event attribute. Because of this there is no need to Subscribe/Unsubscribe from events with the usual +=/-=
[TextChannelEvent(TextChannelStatus.TextChannelConnecting)]
private void OnTextChannelConnecting(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Is Connecting");
}
[TextChannelEvent(TextChannelStatus.TextChannelConnected)]
private void OnTextChannelConnected(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Has Connected : Channel Type == {channelSession.Channel.Type}");
}
[TextChannelEvent(TextChannelStatus.TextChannelDisconnecting)]
private void OnTextChannelDisconnecting(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Is Disconnecting");
}
[TextChannelEvent(TextChannelStatus.TextChannelDisconnected)]
private void OnTextChannelDisconnected(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Has Disconnected");
}
Dynamic Async Events
Make sure the parameter in your method matches the event type. See what parameter is required for each AudioChannel Event here. Dynamic events will dynamically invoke your method at runtime on every game object that has a dynamic event attribute. Because of this there is no need to Subscribe/Unsubscribe from events with the usual +=/-=
More information on the methods called in any async method can be found here. Unity Gaming Services Examples. They are direct copies from Unity's docs. These are just examples and don't mimic real world use cases
[TextChannelEventAsync(TextChannelStatus.TextChannelConnecting)]
private async void OnTextChannelConnectingAsync(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Is Connecting");
await LoadPlayerData();
}
[TextChannelEventAsync(TextChannelStatus.TextChannelConnected)]
private async void OnTextChannelConnectedAsync(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Has Connected : Channel Type == {channelSession.Channel.Type}");
await GetJoinedLobbies();
}
[TextChannelEventAsync(TextChannelStatus.TextChannelDisconnecting)]
private async void OnTextChannelDisconnectingAsync(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Is Disconnecting");
await SavePlayerData();
}
[TextChannelEventAsync(TextChannelStatus.TextChannelDisconnected)]
private async void OnTextChannelDisconnectedAsync(IChannelSession channelSession)
{
Debug.Log($"{channelSession.Channel.Name} Has Disconnected");
await RemovePlayerFromLobby();
}
Last updated
Was this helpful?