Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Not getting the OnParticipantAdded events sometimes

Discussion in 'Vivox (Voice & Text Chat)' started by PrecisionDave, Mar 20, 2023.

  1. PrecisionDave

    PrecisionDave

    Joined:
    Dec 15, 2022
    Posts:
    8
    Hi,
    Sometimes, one or more of the clients joining a voice channel are not getting the OnParticipantAdded event, called (verified by log files), but the channel does have full voice chat for both participantes.
    e.g.
    client1 - starts first, creates channel and joins - event notifying of user joining is called (self = true)
    client2 - joins the multiplayer session, joins channel, sees event for joining (self = true) and also gets event for other user joining (self = false)
    client one is never notified of user 2 joining -then all calls to check if user's muted/talking/AudioEnergy state fail - and when client 1 iterates through the channel - only 1 user is in its participants list.

    So while client's one participant list is wrong (missing client 2) the audio stream is correct.


    Any ideo how to ensure / force an update of the participants list to all clients when a user joins?

    DR
     
  2. PrecisionDave

    PrecisionDave

    Joined:
    Dec 15, 2022
    Posts:
    8
    Oh ya - v.5.18.1 -- can't got o 5.19 because that SDK disables the quest volume control on the headset
     
  3. MurphyMurph_21

    MurphyMurph_21

    Joined:
    Jul 3, 2020
    Posts:
    73
    Can you show me your participant event callback code so I can see what might be wrong. @PrecisionDave
     
  4. PrecisionDave

    PrecisionDave

    Joined:
    Dec 15, 2022
    Posts:
    8
    Sure - thanks in advance for any insight!
    overview- Each client joins the same way:
    1. Join Unreal dedicated server
    2. Channel name is replicated from server.
    3. Client requests, then gets Login and Join Tokens from server
    4. initiates Login, which then calls the callback - OnLoginComplete
    5. If successful, joins the channel with the following

    Code (CSharp):
    1.  
    2. ILoginSession& LoginSession = VivoxModule->VoiceClient().GetLoginSession(ClientAccount);
    3.     LoginSession.SetParticipantSpeakingUpdateRate(ParticipantSpeakingUpdateRate::Update5Hz);
    4.     ChannelId Channel = ChannelId(VIVOX_VOICE_ISSUER, ChannelName, VIVOX_VOICE_DOMAIN, ChannelType::Positional, POSITIONAL_PROPERTIES);
    5.     IChannelSession& ChannelSession = LoginSession.GetChannelSession(Channel);
    6.  
    7.     // IMPORTANT: In production, developers should NOT use the insecure client-side token generation methods.
    8.     // To generate secure access tokens, call GenerateClientJoinToken or a custom implementation from your game server.
    9.     // This is important not only to secure access to Chat features, but tokens issued by the client could
    10.     // appear expired if the client's clock is set incorrectly, resulting in rejection.
    11. #if 0//CLIENT_TOKEN_GEN is not done -- JoinToken is generated on the dedicated server
    12.     //
    13.     JoinToken = AVivoxProvider::GenerateJoinToken(LoginSession, ChannelSession);
    14. #endif
    15.  
    16.     BindChannelSessionHandlers(ChannelSession);
    17.  
    18.     ChannelSession.BeginConnect(true,
    19.         false,
    20.         false,
    21.         JoinToken,
    22.         IChannelSession::FOnBeginConnectCompletedDelegate::CreateLambda([&](VivoxCoreError Status) { OnJoinComplete(Status); }));
    23.  
    The BindChannelSessionHandlers() call is:

    Code (CSharp):
    1. void AVivoxProvider::BindChannelSessionHandlers(IChannelSession& ChannelSession)
    2. {
    3.     ChannelSession.EventAfterParticipantAdded.AddUObject(this, &AVivoxProvider::OnChannelParticipantAdded);
    4.     ChannelSession.EventBeforeParticipantRemoved.AddUObject(this, &AVivoxProvider::OnChannelParticipantRemoved);
    5.     ChannelSession.EventAfterParticipantUpdated.AddUObject(this, &AVivoxProvider::OnChannelParticipantUpdated);
    6.     ChannelSession.EventAudioStateChanged.AddUObject(this, &AVivoxProvider::OnChannelAudioStateChanged);
    7.     ChannelSession.EventTextStateChanged.AddUObject(this, &AVivoxProvider::OnChannelTextStateChanged);
    8.     ChannelSession.EventChannelStateChanged.AddUObject(this, &AVivoxProvider::OnChannelStateChanged);
    9.     ChannelSession.EventTextMessageReceived.AddUObject(this, &AVivoxProvider::OnChannelTextMessageReceived);
    10. }
    and..
    Code (CSharp):
    1. void AVivoxProvider::OnChannelParticipantAdded(const IParticipant& NewParticipant)
    2. {
    3.     ChannelId Channel = NewParticipant.ParentChannelSession().Channel();
    4.     LocalShipLogger(FString::Format(TEXT("User {0} has joined channel {1} (self = {2})"), { *NewParticipant.Account().Name(), *Channel.Name() , NewParticipant.IsSelf() ? TEXT("true") : TEXT("false")}));
    5.  
    6.  
    7. }
    8.  
    Is where I track the addition of Participants to the channel.

    For a two client set up, I sometimes see output like: (other output removed)
    In first client to join server's log file:
    User ClientName_12462881 has joined channel POSVOIPChannel_2023_3_20_11_51_29_16526840 (self = true)
    In second Client's log file:
    User ClientName_204822832 has joined channel POSVOIPChannel_2023_3_20_11_51_29_16526840 (self = true)
    User ClientName_12462881 has joined channel POSVOIPChannel_2023_3_20_11_51_29_16526840 (self = false)

    No other User has Joined (or the corresponding, but not shown User has left channel) output is present.
    So although client 1 has only had one participant added event (self) the connection is solid and the two users can converse as expected.
     
  5. MurphyMurph_21

    MurphyMurph_21

    Joined:
    Jul 3, 2020
    Posts:
    73
    Well thanks for sharing the code but you probably should of mentioned you were using Unreal Engine in the question. For some reason Unity hasnt created 2 seperate forums for the different game engines.

    I only know how to use Vivox in Unity game engine. I could understand what the code was doing and it is very similar of how c# does it but I don't know enough of the c++ implementation to help you. Sorry, hope someone helps you tho