internal Task JoinLobby(DiscordLobby discordLobby) { if (_connectedLobbies.ContainsKey((long)discordLobby.Id)) { throw new InvalidOperationException("[Discord] Already connected to lobby."); } Assert.IsNotNull(discordLobby); var future = new TaskCompletionSource <object>(); _lobbyManager.ConnectLobby((long)discordLobby.Id, discordLobby.Secret, (DiscordApp.Result result, ref DiscordApp.Lobby lobby) => { if (result != DiscordApp.Result.Ok) { future.SetException(DiscordUtility.ToError(result)); return; } discordLobby._data = lobby; _connectedLobbies.Add(lobby.Id, discordLobby); _lobbyManager.ConnectNetwork(lobby.Id); _lobbyManager.OpenNetworkChannel(lobby.Id, (byte)Reliability.Reliable, true); _lobbyManager.OpenNetworkChannel(lobby.Id, (byte)Reliability.Unreliable, false); discordLobby.Members.Refresh(); future.SetResult(null); }); return(future.Task); }
void LobbyCreated(Result result, ref Lobby lobby) { lobbyCreated = true; switch (result) { case (Result.Ok): currentLobby = lobby; lobbyManager.ConnectNetwork(currentLobby.Id); lobbyManager.OpenNetworkChannel(currentLobby.Id, 0, true); lobbyManager.OpenNetworkChannel(currentLobby.Id, 1, false); break; default: OnServerError?.Invoke(0, new Exception("Failed to start discord lobby, Reason: " + result)); Debug.LogError("Discord Transport - ERROR: " + result.ToString()); break; } }
void SetupLobbyChannels(long lobbyId) { _lobbyManager.ConnectNetwork(lobbyId); _lobbyManager.OpenNetworkChannel(lobbyId, (byte)Reliability.Reliable, true); _lobbyManager.OpenNetworkChannel(lobbyId, (byte)Reliability.Unreliable, false); }