Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Resolved Problem in implementing Vivox Positional channels

Discussion in 'Vivox (Voice & Text Chat)' started by Muhammad_Saqib, Aug 4, 2023.

  1. Muhammad_Saqib

    Muhammad_Saqib

    Joined:
    Jun 9, 2023
    Posts:
    4
    I am trying to implement Vivox Positional channel, currently I am using this piece of code to check either our player present in a channel or not and it is returning true
    Code (CSharp):
    1. IChannelSession _session = VivoxManager.instance._channelSession;
    2.         if (_session.Channel.Type == ChannelType.Positional && _session.ChannelState == ConnectionState.Connected && _session.AudioState == ConnectionState.Connected)
    3.         {
    4.             Debug.Log("Channel is present");
    5.             return true;
    6.         }
    7.         else
    8.         {
    9.             return false;
    10.         }
    On the other hand `AfterKeyAdded` event of Vivox working perfectly fine in non-positional channels(it is showing a message to everyone that new user joined in)
    But when it comes to positional channels this event stop calling (it is not showing about new or previosly connected users)
    I am using this code for this purpose

    Code (CSharp):
    1.  ` _channelSession.Participants.AfterKeyAdded += OnParticiplentAdded;
    2. private void OnParticiplentAdded(object sender, KeyEventArg<string> e)
    3.     {
    4.         //ValidateArgs(new object[] { sender, keyEventArg });
    5.         Debug.Log(_loginSession.LoginSessionId.ToString());
    6.         var source = (VivoxUnity.IReadOnlyDictionary<string, IParticipant>)sender;
    7.         var participant = source[e.Key];
    8.         var username = participant.Account.DisplayName;
    9.         var channel = participant.ParentChannelSession.Key;
    10.         var channelSession = participant.ParentChannelSession;
    11.         Debug.Log(username + " have joined");
    12.         UIManager.instance.ChangeChannelOptionsPanelState(false);
    13.     }`
     
  2. MurphyMurph_21

    MurphyMurph_21

    Joined:
    Jul 3, 2020
    Posts:
    73
    What code are you using to join a Positional Channel?
     
  3. Muhammad_Saqib

    Muhammad_Saqib

    Joined:
    Jun 9, 2023
    Posts:
    4

    I am using this code to join the positional channel

    Code (CSharp):
    1. public void JoinChannel(string channelName, ChannelType channelType, bool connectAudio, bool connectText, bool transmissionSwitch,
    2. Channel3DProperties properties = null, bool joinMuted = false)
    3.     {
    4.         if (properties == null)
    5.         {
    6.             Debug.Log("Creating new properities");
    7.             properties = new Channel3DProperties();
    8.         }
    9.         if (_loginSession.State == LoginState.LoggedIn)
    10.         {
    11.             Channel channel = new Channel(channelName, channelType, properties);
    12.  
    13.             IChannelSession channelSession = _loginSession.GetChannelSession(channel);
    14.             _channelSession = channelSession;
    15.             _channelSession.Participants.AfterKeyAdded += OnParticiplentAdded;
    16.             channelSession.BeginConnect(connectAudio, connectText, transmissionSwitch, channelSession.GetConnectToken(), ar =>
    17.             {
    18.                 try
    19.                 {
    20.                     channelSession.EndConnect(ar);
    21.                 }
    22.                 catch (Exception e)
    23.                 {
    24.                     Debug.LogError($"Could not connect to channel: {e.Message}");
    25.                     return;
    26.                 }
    27.             });
    28.         }
    29.         else
    30.         {
    31.             Debug.LogError("Can't join a channel when not logged in.");
    32.         }
    33.     }
     
  4. MurphyMurph_21

    MurphyMurph_21

    Joined:
    Jul 3, 2020
    Posts:
    73
    I tested your code with EasyCodeForVivox and it worked. I tried joining non-positional channel first, then 3d and vice versa, and both ways the event is fired for users joining non-positional and 3d Positional channels. Based on the code you showed the event should be working, so the problem lies elsewhere in your code or UI, when a user joins Positional channels
     
  5. Muhammad_Saqib

    Muhammad_Saqib

    Joined:
    Jun 9, 2023
    Posts:
    4
    Thanks a lot Murphy
    Yeah! the problem was with UI and it was passing wrong channel name each time,
    After debugging it starts working
     
    MurphyMurph_21 likes this.