Join / Leave Channel

You can have up to 10 channels in a login session with Vivox Voice and Text Chat. You can have only one 3D Positional channel at any point and time though. For example you can have

  • 9 Non-positional channels, 1 3D positional

  • 10 Non-Positional Channels, 0 3D positional

3D positional channels are meant for 3D games because you need to send Vector3 values to Vivox

You can have up to <= 200 people in a channel (Non-positional / 3DPositional)

If you are an Enterprise customer, you can use the Large 3D channels setting for 3D Positional channels to have up to 2,000 players. Check out Vivox Documentation for more info

Inherit from EasyManager.cs

using EasyCodeForVivox;

public class VivoxManager : EasyManager
{

}

Inject EasyChannel

using EasyCodeForVivox;
using EasyCodeForVivox.Extensions;
using UnityEngine;
using VivoxUnity;
using Zenject;

public class VivoxChannel : MonoBehaviour
{
    EasyChannel _channel;

    [Inject]
    public void Initialize(EasyChannel channel)
    {
        _channel = channel;
    }
}

The following examples use the same method 2 methods but in different ways. I will break down the method parameters of each method before explaining how to use them

JoinChannel

TypeParameterExplanation

string

userName

The name of the user joining the channel

string

channelName

The name of the channel to join. If it does not exist Vivox will create it

bool

includeVoice

Should this channel have Audio/Voice chat capabilities

bool

includeText

Should this channel have Text chat capabilities

bool

switchTransmission

Should the player stop transmitting any Audio/Voice/Text in other channels and Only transmit to this channel. Overrides the current LoginSession SetTransmissionMode settings

ChannelType

channelType

What type of channel should this be?

bool

joinMuted

(Optional) Should the user join the channel muted. Defaults to false

Channel3DProperties

channel3DProperties

(Optional) The settings for a 3d Positional channel. If 3d settings are included for a channel that isn't 3d, the settings are ignored. Defaults to Vivox Recommended 3d settings

JoinChannelRegion - Used for large scale games - Vivox Documentation

TypeParameterExplanation

string

userName

The name of the user joining the channel

string

channelName

The name of the channel to join. If it does not exist Vivox will create it

string

matchRegion

The region (Vivox also calls this a shard) of the server your player is closest to.

string

matchHash

A hashed value (Unique Id) of the match's name all players in the same channel/channels are connected to

bool

includeVoice

Should this channel have Audio/Voice chat capabilities

bool

includeText

Should this channel have Text chat capabilities

bool

switchTransmission

Should the player stop transmitting any Audio/Voice/Text in other channels and only transmit to this channel. Overrides the current LoginSession SetTransmissionMode settings

ChannelType

channelType

What type of channel should this be?

bool

joinMuted

(Optional) Should the user join the channel muted. Defaults to false

Channel3DProperties

channel3DProperties

(Optional) The settings for a 3d Positional channel. If 3d settings are included for a channel that isn't 3d, the settings are ignored. Defaults to Vivox Recommended 3d settings

Joining an Echo Channel

This type of channel is used for Mic testing. Check out this blog post for more info

  • Joins the player "username" to an Echo channel called "echo".

  • Audio is activated in channel so the player can test their mic.

  • Since "username" is the only player in the channel, Text capabilities are turned off.

  • Transmission is switched to the current channel which overrides any previous settings set in the current LoginSession (This means only Audio/Voice/Text will transmit through this Echo channel and no other channel).

  • Channel type chosen is Echo channel.

  • Join muted is set to false because we want the player to hear themselves speaking so they can test their mic

  • No 3d Settings are created/added because it is not a 3d channel

EasyManager

public void JoinEchoChannel()
{
    JoinChannel("username", "echo", true, false, true, ChannelType.Echo, joinMuted: false);
}

EasyChannel

public void JoinEchoChannel()
{
    _channel.JoinChannel("username", "echo", true, false, true, ChannelType.Echo, joinMuted: false);
}

Joining a Non-Positional (Conference) Channel

This type of channel is normal chat - Vivox Documentation

  • Joins the player "username" to a NonPositional (Conference) channel called "chat".

  • Audio is activated in channel so the player can talk to other players.

  • Text capabilities are turned on so player can chat with other players.

  • Transmission is not switched to current channel. Any previous settings set in the current LoginSession will be persisted.

  • Channel type chosen is NonPositional channel.

  • Join muted is set to false because we want the player to hear other players in channel as soon as they join

  • No 3d Settings are created/added because it is not a 3d channel

EasyManager

public void JoinChannel()
{
    JoinChannel("username", "chat", true, true, false, ChannelType.NonPositional, joinMuted: false);
}

EasyChannel

public void JoinChannel()
{
    _channel.JoinChannel("username", "chat", true, true, false, ChannelType.NonPositional, joinMuted: false);
}

Joining a 3D Channel

This type of channel is for 3d video games where Audio/Voice and Text capabilities are based on how close you are to other players. - Vivox Documentation

  • Joins the player "username" to a 3DPositional channel called "3D".

  • Audio is activated in channel so the player can talk to other players.

  • Text capabilities are turned off because I don't want players text/chat to be lost/discarded if they aren't close to each other on the map. I also don't want everyone to be able to text each other, only squads can text within their squad (use NonPositional Channel).

  • Transmission is not switched to current channel. Any previous settings set in the current LoginSession will be persisted.

  • Channel type chosen is 3DPositional channel.

  • Join muted is set to false because we want the player to hear other players in channel as soon as they join

  • I have created 3d Settings with the default values that Vivox recommends, and I am passing in the settings so when the 3d channel is created it will apply my chosen settings.

EasyManager

public void Join3DChannel()
{
    var channelProperties = new Channel3DProperties(32, 1, 1.0f, AudioFadeModel.InverseByDistance);

    JoinChannel("username", "3D", true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);
}

EasyChannel

public void Join3DChannel()
{
    var channelProperties = new Channel3DProperties(32, 1, 1.0f, AudioFadeModel.InverseByDistance);

    _channel.JoinChannel("username", "3D", true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);
}

Joining a 3D Channel in Specific Region

This is used for large scale games or when using multiple channels such as 3DPositional (for all players) and NonPositional (for squad members). Vivox Documentation

  • Joins the player "username" to a 3DPositional channel called "3D".

  • I am assigning the Match Region to "NA" which is the continent code for North America. You can also use country codes ("US" for United States) if you know which country your players are in. You can also do "us-west-1" or "us-east-1" like AWS (Amazon Web Services) does if you are separating players by their location closest to your servers. I do not know what regions Vivox servers are in, but they handle the sharding for you as long you use consistent Region identifiers for all matches in that region Vivox will handle the sharding for you. Check out this SlideDeck (Slide 8) for more info

  • I am using a Match Hash of the lobby id/match name (identifier). My example is for demo purposes and not production ready code. This should be a unique value for every game session. If using Unity's Lobby Service you can use the Lobby Id which is a unique value for the current match all players are connected to

For my example with the GetMD5Hash(), if 2 match names are the same, the hash will be the same as well and this could create conflicts. It is better to use a GUID (unique identifier) for each match if you are implementing your own lobby/matchmaking system

  • Audio is activated in channel so the player can talk to other players.

  • Text capabilities are turned off because I don't want players text/chat to be lost/discarded if they aren't close to each other on the map. I also don't want everyone to be able to text each other, only squads can text within their squad (use NonPositional Channel).

  • Transmission is not switched to current channel. Any previous settings set in the current LoginSession will be persisted.

  • Channel type chosen is 3DPositional channel.

  • Join muted is set to false because we want the player to hear other players in channel as soon as they join

  • I have created 3d Settings with the default values that Vivox recommends, and I am passing in the settings so when the 3d channel is created it will apply my chosen settings.

  • lobby.Id - Gets Lobby Id from Unity's Lobby Service. Lobby Id is a unique for each lobby, so it is okay to use as a match hash. Read More here

  • Method is async void because Unity's Lobby Service uses asynchronous programming

  • GetMD5Hash() -Namespace using EasyCodeForVivox.Extensions;

Lobby Namespaces

using Unity.Services.Lobbies;

using Unity.Services.Lobbies.Models;

EasyManager

public async void Join3DRegionChannel()
{
    var channelProperties = new Channel3DProperties(32, 1, 1.0f, AudioFadeModel.InverseByDistance);

    // using match hash
    var matchHash = "lobby name".GetMD5Hash();
    JoinChannelRegion("userName", "3D", "NA", matchHash, true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);

    //using Unity's Lobby Service
    Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName: "lobby name", maxPlayers: 4);
    JoinChannelRegion("userName", "3D", "NA", lobby.Id, true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);
}

EasyChannel

public async void Join3DRegionChannel()
{
    var channelProperties = new Channel3DProperties(32, 1, 1.0f, AudioFadeModel.InverseByDistance);

    // using match hash
    var matchHash = "lobby name".GetMD5Hash();
    _channel.JoinChannelRegion("userName", "3D", "NA", matchHash, true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);

    //using Unity's Lobby Service
    Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName: "lobby name", maxPlayers: 4);
    _channel.JoinChannelRegion("userName", "3D", "NA", lobby.Id, true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);
}

Joining a NonPositional Channel in Specific Region

This is used for large scale games or when using multiple channels such as 3DPositional (for all players) and NonPositional (for squad members). Vivox Documentation

  • Joins the player "username" to a NonPositional channel called "squad1".

  • I am assigning the Match Region to "NA" which is the continent code for North America. You can also use country codes ("US" for United States) if you know which country your players are in. You can also do "us-west-1" or "us-east-1" like AWS (Amazon Web Services) does if you are separating players by their location closest to your servers. I do not know what regions Vivox servers are in, but they handle the sharding for you as long you use consistent Region identifiers for all matches in that region Vivox will handle the sharding for you. Check out this SlideDeck (Slide 8) for more info

  • I am using a Match Hash of the lobby id/match name (identifier). My example is for demo purposes and not production ready code. This should be a unique value for every game session. If using Unity's Lobby Service you can use the Lobby Id which is a unique value for the current match all players are connected to

For my example with the GetMD5Hash(), if 2 match names are the same, the hash will be the same as well and this could create conflicts. It is better to use a GUID (unique identifier) for each match if you are implementing your own lobby/matchmaking system

  • Audio is activated in channel so the player can talk to their squad members.

  • Text capabilities are turned on so player can chat with their squad members.

  • Transmission is not switched to current channel. Any previous settings set in the current LoginSession will be persisted.

  • Channel type chosen is NonPositional channel.

  • Join muted is set to false because we want the player to hear their squad members in channel as soon as they join

  • No 3d Settings are created/added because it is not a 3d channel

  • lobby.Id - Gets Lobby Id from Unity's Lobby Service. Lobby Id is a unique for each lobby, so it is okay to use as a match hash. Read More here

  • Method is async void because Unity's Lobby Service uses asynchronous programming

  • GetMD5Hash() -Namespace using EasyCodeForVivox.Extensions;

EasyManager

public async void JoinSquadRegionChannel()
{
    var channelProperties = new Channel3DProperties(32, 1, 1.0f, AudioFadeModel.InverseByDistance);

    // using match hash
    var matchHash = "lobby name".GetMD5Hash();
    JoinChannelRegion("userName", "sqaud1", "NA", matchHash, true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);

    //using Unity's Lobby Service
    Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName: "lobby name", maxPlayers: 4);
    JoinChannelRegion("userName", "sqaud1", "NA", lobby.Id, true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);
}

EasyChannel

public async void JoinSquadRegionChannel()
{
    var channelProperties = new Channel3DProperties(32, 1, 1.0f, AudioFadeModel.InverseByDistance);

    // using match hash
    var matchHash = "lobby name".GetMD5Hash();
    _channel.JoinChannelRegion("userName", "sqaud1", "NA", matchHash, true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);

    //using Unity's Lobby Service
    Lobby lobby = await LobbyService.Instance.CreateLobbyAsync(lobbyName: "lobby name", maxPlayers: 4);
    _channel.JoinChannelRegion("userName", "sqaud1", "NA", lobby.Id, true, false, false, ChannelType.Positional, joinMuted: false, channel3DProperties: channelProperties);
}

Last updated