【m】开发完成

This commit is contained in:
2026-04-30 23:27:34 +08:00
parent c0dd21b524
commit f04556e609
3 changed files with 13 additions and 8 deletions

View File

@@ -395,7 +395,9 @@ namespace Unity.RenderStreaming
peer.OnConnectHandler += () => onConnect?.Invoke(connectionId);
peer.OnDisconnectHandler += () =>
{
_signaling?.CloseConnection(connectionId);
// PeerConnection失败时不自动发送disconnect避免重复断开通知。
// 主动断开由 Handler 的 DeleteConnection 触发,远端断开由服务器的 disconnect 消息触发。
// 这里只触发 onDisconnect 事件通知 Handler 进行资源清理。
onDisconnect?.Invoke(connectionId);
};
peer.OnDataChannelHandler += channel => onAddChannel?.Invoke(connectionId, channel); ;
@@ -473,10 +475,11 @@ namespace Unity.RenderStreaming
void OnParticipantLeftHandler(ISignaling signaling, ParticipantEventData e)
{
// 参与者离开时销毁对应的PeerConnection
// 参与者离开时,销毁对应的PeerConnection不触发onDeletedConnection事件
// 因为onParticipantLeft已经会通知Handler进行资源清理避免重复通知
if (_mapConnectionIdAndPeer.ContainsKey(e.participantId))
{
DestroyConnection(e.participantId);
DeletePeerConnection(e.participantId);
}
onParticipantLeft?.Invoke(e.connectionId, e.participantId);
}