Skip to main content

VivoxSession

A class in Root.Township, Alta.Voice.

One joined Vivox voice or text channel. Connects with a token from the API and pairs each participant with the matching in-game player. Client side.

Constructors​

MemberWhat it is
VivoxSession(VivoxChannel channel, ILoginSession login)Creates a VivoxSession from channel and login.

Fields​

2 private and internal fields
MemberWhat it is
private static Logger loggerClass logger.
private readonly IChannelSession sessionThe underlying Vivox channel session.

Properties​

MemberWhat it is
VivoxChannel Channel { get; }The Vivox channel this session is for.
bool IsConnected { get; private set; }True once the channel has been joined.
VivoxText VivoxText { get; }Text chat for the channel, or null if text is off.
VivoxVoice VivoxVoice { get; }Voice for the channel, or null if voice is off.

Events​

MemberWhat it is
event Action<VivoxSession> AudioConnectedRaised when the channel's audio connects.
event Action<VivoxSession> ConnectionFailedRaised when connecting fails after a token was got.
event Action<IParticipant> PlayerPairedRaised when a participant is matched to an in-game player and set as their Voice.
event Action<VivoxSession> TextConnectedRaised when the channel's text chat connects.

Methods​

MemberWhat it is
async void Initialize()Gets a connect token (up to 5 tries, waiting longer each time) and joins the channel.
void SetMuted(string username, bool isMuted)Mutes or unmutes a participant locally, found by username in the participant key.
void Terminate()Disconnects from the channel.
5 private and internal methods
MemberWhat it is
private async Task<bool> ConnectAsync(string accessToken)Connects the channel session with the access token and returns whether it worked.
private void PairWithPlayer(string key, IParticipant player, float delay = 0.5)Links a Vivox participant to the matching player by user ID, retrying with a doubling delay until the player shows up or the participant leaves.
private void PlayerJoined(object sender, KeyEventArg<string> e)Called when a participant joins; logs it and starts pairing them with a player.
private void PlayerLeft(object sender, KeyEventArg<string> e)Called when a participant leaves. Only logs it.
private void SessionPropertyChanged(object sender, PropertyChangedEventArgs e)Logs session changes and raises AudioConnected or TextConnected when that state becomes connected.

Used in​

Members of other types that take, return or hold a VivoxSession: