浏览代码

Fixing a bug where a player could disconnect from a lobby while Vivox was still connecting and end up outside the lobby but inside the voice channel. Now, if that case is detected, we ensure that the disconnect message to Vivox is sent after its connection process completes.

/main/staging/vivox_bug_voice_outside_lobby
nathaniel.buck@unity3d.com 3 年前
当前提交
8d8babbd
共有 1 个文件被更改,包括 34 次插入1 次删除
  1. 35
      Assets/Scripts/Vivox/VivoxSetup.cs

35
Assets/Scripts/Vivox/VivoxSetup.cs


m_channelSession.BeginConnect(true, false, true, token, result =>
{
try
{ m_channelSession.EndConnect(result);
{
// Special case: It's possible for the player to leave the lobby between the time we called BeginConnect and the time we hit this callback.
// If that's the case, we should abort the rest of the connection process.
if (m_channelSession.ChannelState == ConnectionState.Disconnecting || m_channelSession.ChannelState == ConnectionState.Disconnected)
{
UnityEngine.Debug.LogWarning("Vivox channel is already disconnecting. Terminating the channel connect sequence.");
HandleEarlyDisconnect();
return;
}
m_channelSession.EndConnect(result);
onComplete?.Invoke(true);
foreach (VivoxUserHandler userHandler in m_userHandlers)
userHandler.OnChannelJoined(m_channelSession);

onComplete?.Invoke(false);
m_channelSession?.Disconnect();
}
});
}

{
if (m_channelSession != null)
{
// Special case: The EndConnect call requires a little bit of time before the connection actually completes, but the player might
// disconnect before then. If so, sending the Disconnect now will fail, and the played would stay connected to voice while no longer
// in the lobby. So, wait until the connection is completed before disconnecting in that case.
if (m_channelSession.ChannelState == ConnectionState.Connecting)
{
UnityEngine.Debug.LogWarning("Vivox channel is trying to disconnect while trying to complete its connection. Will wait until connection completes.");
HandleEarlyDisconnect();
return;
}
ChannelId id = m_channelSession.Channel;
m_channelSession?.Disconnect(
(result) => { m_loginSession.DeleteChannelSession(id); m_channelSession = null; });

}
private void HandleEarlyDisconnect()
{
Locator.Get.UpdateSlow.Subscribe(DisconnectOnceConnected, 0.2f);
}
private void DisconnectOnceConnected(float unused)
{
if (m_channelSession?.ChannelState == ConnectionState.Connecting)
return;
Locator.Get.UpdateSlow.Unsubscribe(DisconnectOnceConnected);
LeaveLobbyChannel();
}
/// <summary>

正在加载...
取消
保存