如何在Godot 4中断开与WebRTC大厅的连接?

问题描述 投票:0回答:1

有谁知道如何在建立连接后断开与 RTC 大厅的连接,以便用户可以返回主大厅(由主 WebSocket 服务器组织)并可能加入另一个 RTC 大厅?

到目前为止我已经尝试过类似的功能

#my rtc peer
var peer_rtc : WebRTCMultiplayerPeer = WebRTCMultiplayerPeer.new()
#Option A - works well but the once the host of previous lobby tries to connect a different lobby
#the 2nd user works fine and syncs everything, but the host can't see the other users
#close the multiplayer peer and re-create the mesh needed for RTC
peer_rtc.close()
peer_rtc.create_mesh(self.id)
networking webrtc godot gdscript godot4
1个回答
0
投票

我想我找到了解决方案,到目前为止似乎有效......

var peers = peer_rtc.get_peers()
for peerID in peers:
    peer_rtc.remove_peer(peerID)
© www.soinside.com 2019 - 2024. All rights reserved.