summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-11-01 20:35:04 +0100
committerGitHub <noreply@github.com>2022-11-01 20:35:04 +0100
commit0a0e99cadc6e250ff2ee27ef31760eb9c2e21040 (patch)
treef790d365bebbfad3c39b96c7b879c9cd6f6506f2 /scene/main
parente6751549cf7247965d1744b8c464f5e901006f21 (diff)
parent39f3d9d59e80d5a9f62925abca596d87ce1e4d0f (diff)
Merge pull request #67982 from Faless/mp/4.x_disconnect_close
[MP] Add MultiplayerPeer disconnect_peer, close.
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);
};