summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-10-22 17:49:40 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-10-28 21:18:01 +0200
commit39f3d9d59e80d5a9f62925abca596d87ce1e4d0f (patch)
treee958ee207578ecf5912210377db44496faa5cc6f /scene/main
parent028db9f2b5b6d2ca9a00d3b08c17f82b5298e149 (diff)
[MP] Add MultiplayerPeer disconnect_peer, close.
Update ENet, WebRTC, and WebSocket to support peer disconnection and unify the close function.
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/multiplayer_peer.cpp4
-rw-r--r--scene/main/multiplayer_peer.h5
2 files changed, 9 insertions, 0 deletions
diff --git a/scene/main/multiplayer_peer.cpp b/scene/main/multiplayer_peer.cpp
index 462dc1babb..b4e5b11abd 100644
--- a/scene/main/multiplayer_peer.cpp
+++ b/scene/main/multiplayer_peer.cpp
@@ -94,6 +94,8 @@ void MultiplayerPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_packet_mode"), &MultiplayerPeer::get_packet_mode);
ClassDB::bind_method(D_METHOD("poll"), &MultiplayerPeer::poll);
+ ClassDB::bind_method(D_METHOD("close"), &MultiplayerPeer::close);
+ ClassDB::bind_method(D_METHOD("disconnect_peer", "peer", "force"), &MultiplayerPeer::disconnect_peer, DEFVAL(false));
ClassDB::bind_method(D_METHOD("get_connection_status"), &MultiplayerPeer::get_connection_status);
ClassDB::bind_method(D_METHOD("get_unique_id"), &MultiplayerPeer::get_unique_id);
@@ -213,6 +215,8 @@ void MultiplayerPeerExtension::_bind_methods() {
GDVIRTUAL_BIND(_get_packet_peer);
GDVIRTUAL_BIND(_is_server);
GDVIRTUAL_BIND(_poll);
+ GDVIRTUAL_BIND(_close);
+ GDVIRTUAL_BIND(_disconnect_peer, "p_peer", "p_force");
GDVIRTUAL_BIND(_get_unique_id);
GDVIRTUAL_BIND(_set_refuse_new_connections, "p_enable");
GDVIRTUAL_BIND(_is_refusing_new_connections);
diff --git a/scene/main/multiplayer_peer.h b/scene/main/multiplayer_peer.h
index 63ce66871e..4b5909538e 100644
--- a/scene/main/multiplayer_peer.h
+++ b/scene/main/multiplayer_peer.h
@@ -82,9 +82,12 @@ public:
virtual TransferMode get_packet_mode() const = 0;
virtual int get_packet_channel() const = 0;
+ virtual void disconnect_peer(int p_peer, bool p_force = false) = 0;
+
virtual bool is_server() const = 0;
virtual void poll() = 0;
+ virtual void close() = 0;
virtual int get_unique_id() const = 0;
@@ -139,6 +142,8 @@ public:
EXBIND0RC(int, get_packet_channel);
EXBIND0RC(bool, is_server);
EXBIND0(poll);
+ EXBIND0(close);
+ EXBIND2(disconnect_peer, int, bool);
EXBIND0RC(int, get_unique_id);
EXBIND0RC(ConnectionStatus, get_connection_status);
};