VivoxClient
A class in Root.Township, Alta.Voice.
Wrapper around the Vivox voice and text chat client: login, audio devices, channels and muting. Client only; one is made by VivoxManager and reached through VivoxManager.Instance.Client.
- Listed in Networking and servers
Constructors
| Member | What it is |
|---|---|
VivoxClient() | Creates a VivoxClient with default values. |
Fields
| Member | What it is |
|---|---|
ILoginSession loginSession | The Vivox login session, or null when logged out. |
8 private and internal fields
| Member | What it is |
|---|---|
private AccountId account | The Vivox account id for the logged-in user, built from the user id and display name. Null when logged out. |
private readonly Dictionary<string, VivoxSession> channels | Joined channel sessions, keyed by channel name. |
private Client client | The underlying Vivox SDK client, created in the constructor and cleared by Terminate. |
private bool isIntendedMute | Whether the player wants the mic muted, flipped by ToggleMute. Restored when a mod mute is lifted. |
private bool isMutedByMods | Whether moderators have muted this player's mic, set by SetModsMute. While true, ToggleMute does not unmute. |
private static Logger logger | NLog logger for this class. |
private IVivoxVoiceUpdatable positionalChat | The voice session of the last joined voice-enabled channel; its 3D position is updated each Update. |
private static StringBuilder stringBuilder | Shared builder used for login and device log messages. |
Properties
Events
Methods
| Member | What it is |
|---|---|
void JoinChannel(VivoxChannel channel, Action<VivoxText> textCreated, Action<VivoxVoice> voiceCreated) | Joins a channel and calls back when its text or voice part connects. A voice channel becomes the positional one. |
void LeaveChannel(VivoxChannel channel) | Leaves a joined channel and removes its session. |
async Task<bool> Login(int userId, string displayName) | Logs in to Vivox for a user id and display name, then refreshes devices. Logging in twice logs an error and returns true. |
void Logout() | Logs out and clears the session. |
async Task<bool> RefreshDevices() | Refreshes the input and output device lists; true if both worked. |
async Task<bool> SetInputDevice(IAudioDevice device) | Chooses the microphone. |
void SetModsMute(bool isMutedByMods) | Mutes the mic while moderators require it, then restores the player's own mute choice. |
void SetMuted(bool isMuted) | Mutes or unmutes your mic; with a user id, mutes that user in every joined channel. |
void SetMuted(int userId, bool isMuted) | Mutes or unmutes your mic; with a user id, mutes that user in every joined channel. |
async Task<bool> SetOutputDevice(IAudioDevice device) | Chooses the output device. |
void Terminate() | Shuts the Vivox client down. |
void ToggleMute() | Flips the player's chosen mute; it only takes effect if moderators aren't muting them. |
void Update() | Runs Vivox once and updates the positional voice position. Call every frame. |
4 private and internal methods
| Member | What it is |
|---|---|
private void HandleSessionStateChanged() | Runs when the Vivox login state changes; on logged out it calls Logout and logs back in through VivoxManager if the game login is still active. |
private void LogDeviceInfo() | Logs the available, active and effective audio input and output devices. Called after login. |
private void OnPlayerPaired(IParticipant player) | Passes a session's PlayerPaired event on as PlayerJoinedChannel. |
private void SessionPropertyChanged(object sender, PropertyChangedEventArgs e) | Handler for the login session's PropertyChanged; logs the change and calls HandleSessionStateChanged when State changes. |
Used in
Members of other types that take, return or hold a VivoxClient: