gamesdk-and-dispatch icon indicating copy to clipboard operation
gamesdk-and-dispatch copied to clipboard

LobbyManager.ConnectVoice returns Results.Ok even when the user is not connected to the lobby

Open iTakeshi opened this issue 5 years ago • 3 comments

Describe the bug

I'm completely new to the game sdk and got confused with the behavior of LobbyManager.ConnectVoice Suppose I got a lobby struct by GetLobby, but I didn't call ConnectLobby. When I called ConnectVoice for this lobby, even though the current user is not connected to the lobby, the callback function for the ConnectVoice received Discord.Results.Ok (but seemed not "really" connected to the voice).

Steps to reproduce

pseudo-C# code is like:

lobbyManager.Search(search, (result) => {
    if (result == Discord.Result.Ok) {
        var lobbyId = lobbyManager.GetLobbyId(0);
        Console.WriteLine("existing lobby found: {0}", lobbyId);
        lobbyManager.ConnectVoice(lobbyId, (result) => {
            if (result == Discord.Result.Ok) {
                Console.WriteLine("voice connected");  // This always happens
            }
        });
    }
});

Expected behavior

I think it is more natural if ConnectVoice returns some error when the current user is not connected to the lobby.

Implementation specifics

  • Language: C#
  • Game Engine: Unity

iTakeshi avatar Mar 24 '20 16:03 iTakeshi

First off, why are you trying to just lobby search? Your just searching and grabbing arbitrary data, the user has to input themselves a secret if they want to actually "connectlobby". ConnectVoice is returning ok since it is firing and receiving like it is supposed too, your just not actually IN a lobby...? Doesn't mean the callback itself failed, Ok just means it is working as intended firing to Discord -> Api and back.

Jump-Suit avatar Mar 24 '20 22:03 Jump-Suit

Sorry if my explanation was not completely clear, but just like I wrote it was a "pseudo" code, I was not trying to do exactly what the pseudo code looked like --- it is much simplified for "reproducing" the situation.

I know the pseudo-code itself contains a bug that (like you pointed out) it is attempting to ConncectVoice without ConnectLobby, but what I meant was that we (especially for beginners like me) CAN accidentally mistakenly write such code. In such cases, it would be helpful to detect the bug if ConnectVoice returns an error indicating "NotConnectedToLobby", instead of just returning Ok which only implies the API call itself was successful.

iTakeshi avatar Mar 25 '20 04:03 iTakeshi

A simple fix for this could be to add a Result that states "NotConnectedToLobby" (Apologies for not responding to this issue sooner a year later now!) I don't think it would take that much work to add a new result for that.

Jump-Suit avatar Mar 21 '21 16:03 Jump-Suit