summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2021-09-28 12:57:45 +0200
committerGitHub <noreply@github.com>2021-09-28 12:57:45 +0200
commitd18cbdf5e4a1132bfc5f581195f6bf7c3b9bed79 (patch)
treee87200b01a5b55ec516b528be52f382954efe4e5
parent97f050067819c7d1fbef0cb38b071ff31b2b2188 (diff)
parent2d810e8cd948f1e25e514986dc6f9a7cb7c52026 (diff)
Merge pull request #52481 from Faless/net/4.x_native_peers
[Net] Extension system for network peers, webrtc.
-rw-r--r--core/io/packet_peer.cpp46
-rw-r--r--core/io/packet_peer.h23
-rw-r--r--core/io/stream_peer.cpp57
-rw-r--r--core/io/stream_peer.h25
-rw-r--r--core/multiplayer/multiplayer_peer.cpp181
-rw-r--r--core/multiplayer/multiplayer_peer.h80
-rw-r--r--core/register_core_types.cpp3
-rw-r--r--core/variant/native_ptr.h1
-rw-r--r--doc/classes/MultiplayerPeer.xml4
-rw-r--r--doc/classes/MultiplayerPeerExtension.xml99
-rw-r--r--doc/classes/PacketPeerExtension.xml35
-rw-r--r--doc/classes/StreamPeerExtension.xml48
-rw-r--r--modules/enet/doc_classes/ENetMultiplayerPeer.xml2
-rw-r--r--modules/enet/enet_multiplayer_peer.cpp37
-rw-r--r--modules/enet/enet_multiplayer_peer.h40
-rw-r--r--modules/gdnative/SCsub1
-rw-r--r--modules/gdnative/config.py5
-rw-r--r--modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml9
-rw-r--r--modules/gdnative/doc_classes/PacketPeerGDNative.xml9
-rw-r--r--modules/gdnative/doc_classes/StreamPeerGDNative.xml9
-rw-r--r--modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml9
-rw-r--r--modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml9
-rw-r--r--modules/gdnative/gdnative_api.json91
-rw-r--r--modules/gdnative/gdnative_builders.py1
-rw-r--r--modules/gdnative/include/net/godot_net.h122
-rw-r--r--modules/gdnative/include/net/godot_webrtc.h123
-rw-r--r--modules/gdnative/net/SCsub12
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.cpp136
-rw-r--r--modules/gdnative/net/multiplayer_peer_gdnative.h79
-rw-r--r--modules/gdnative/net/packet_peer_gdnative.cpp72
-rw-r--r--modules/gdnative/net/packet_peer_gdnative.h59
-rw-r--r--modules/gdnative/net/register_types.cpp43
-rw-r--r--modules/gdnative/net/register_types.h37
-rw-r--r--modules/gdnative/net/stream_peer_gdnative.cpp77
-rw-r--r--modules/gdnative/net/stream_peer_gdnative.h60
-rw-r--r--modules/gdnative/net/webrtc_gdnative.cpp60
-rw-r--r--modules/gdnative/register_types.cpp3
-rw-r--r--modules/webrtc/SCsub5
-rw-r--r--modules/webrtc/config.py2
-rw-r--r--modules/webrtc/doc_classes/WebRTCDataChannelExtension.xml106
-rw-r--r--modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml4
-rw-r--r--modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml71
-rw-r--r--modules/webrtc/register_types.cpp26
-rw-r--r--modules/webrtc/webrtc_data_channel_extension.cpp215
-rw-r--r--modules/webrtc/webrtc_data_channel_extension.h (renamed from modules/webrtc/webrtc_data_channel_gdnative.h)53
-rw-r--r--modules/webrtc/webrtc_data_channel_gdnative.cpp143
-rw-r--r--modules/webrtc/webrtc_multiplayer_peer.cpp30
-rw-r--r--modules/webrtc/webrtc_multiplayer_peer.h10
-rw-r--r--modules/webrtc/webrtc_peer_connection.cpp24
-rw-r--r--modules/webrtc/webrtc_peer_connection.h7
-rw-r--r--modules/webrtc/webrtc_peer_connection_extension.cpp131
-rw-r--r--modules/webrtc/webrtc_peer_connection_extension.h (renamed from modules/webrtc/webrtc_peer_connection_gdnative.h)47
-rw-r--r--modules/webrtc/webrtc_peer_connection_gdnative.cpp121
-rw-r--r--modules/webrtc/webrtc_peer_connection_js.h3
-rw-r--r--modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml4
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp25
-rw-r--r--modules/websocket/websocket_multiplayer_peer.h7
57 files changed, 1232 insertions, 1509 deletions
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 8da44fd290..87d2b66e5b 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -138,6 +138,7 @@ Error PacketPeer::_get_packet_error() const {
void PacketPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_var", "allow_objects"), &PacketPeer::_bnd_get_var, DEFVAL(false));
ClassDB::bind_method(D_METHOD("put_var", "var", "full_objects"), &PacketPeer::put_var, DEFVAL(false));
+
ClassDB::bind_method(D_METHOD("get_packet"), &PacketPeer::_get_packet);
ClassDB::bind_method(D_METHOD("put_packet", "buffer"), &PacketPeer::_put_packet);
ClassDB::bind_method(D_METHOD("get_packet_error"), &PacketPeer::_get_packet_error);
@@ -151,6 +152,51 @@ void PacketPeer::_bind_methods() {
/***************/
+int PacketPeerExtension::get_available_packet_count() const {
+ int count;
+ if (GDVIRTUAL_CALL(_get_available_packet_count, count)) {
+ return count;
+ }
+ WARN_PRINT_ONCE("PacketPeerExtension::_get_available_packet_count is unimplemented!");
+ return -1;
+}
+
+Error PacketPeerExtension::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_get_packet, r_buffer, &r_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("PacketPeerExtension::_get_packet_native is unimplemented!");
+ return FAILED;
+}
+
+Error PacketPeerExtension::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_put_packet, p_buffer, p_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("PacketPeerExtension::_put_packet_native is unimplemented!");
+ return FAILED;
+}
+
+int PacketPeerExtension::get_max_packet_size() const {
+ int size;
+ if (GDVIRTUAL_CALL(_get_max_packet_size, size)) {
+ return size;
+ }
+ WARN_PRINT_ONCE("PacketPeerExtension::_get_max_packet_size is unimplemented!");
+ return 0;
+}
+
+void PacketPeerExtension::_bind_methods() {
+ GDVIRTUAL_BIND(_get_packet, "r_buffer", "r_buffer_size");
+ GDVIRTUAL_BIND(_put_packet, "p_buffer", "p_buffer_size");
+ GDVIRTUAL_BIND(_get_available_packet_count);
+ GDVIRTUAL_BIND(_get_max_packet_size);
+}
+
+/***************/
+
void PacketPeerStream::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::set_stream_peer);
ClassDB::bind_method(D_METHOD("get_stream_peer"), &PacketPeerStream::get_stream_peer);
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 9a345af3d0..bc1f4aaabf 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -35,6 +35,10 @@
#include "core/object/class_db.h"
#include "core/templates/ring_buffer.h"
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
class PacketPeer : public RefCounted {
GDCLASS(PacketPeer, RefCounted);
@@ -73,6 +77,25 @@ public:
~PacketPeer() {}
};
+class PacketPeerExtension : public PacketPeer {
+ GDCLASS(PacketPeerExtension, PacketPeer);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual int get_available_packet_count() const override;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; ///< buffer is GONE after next get_packet
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
+ virtual int get_max_packet_size() const override;
+
+ /* GDExtension */
+ GDVIRTUAL0RC(int, _get_available_packet_count);
+ GDVIRTUAL2R(int, _get_packet, GDNativeConstPtr<const uint8_t *>, GDNativePtr<int>);
+ GDVIRTUAL2R(int, _put_packet, GDNativeConstPtr<const uint8_t>, int);
+ GDVIRTUAL0RC(int, _get_max_packet_size);
+};
+
class PacketPeerStream : public PacketPeer {
GDCLASS(PacketPeerStream, PacketPeer);
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 27f8d4e88f..8ab025dda1 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -410,6 +410,63 @@ void StreamPeer::_bind_methods() {
////////////////////////////////
+int StreamPeerExtension::get_available_bytes() const {
+ int count;
+ if (GDVIRTUAL_CALL(_get_available_bytes, count)) {
+ return count;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_get_available_bytes is unimplemented!");
+ return -1;
+}
+
+Error StreamPeerExtension::get_data(uint8_t *r_buffer, int p_bytes) {
+ int err;
+ int received = 0;
+ if (GDVIRTUAL_CALL(_get_data, r_buffer, p_bytes, &received, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_get_data is unimplemented!");
+ return FAILED;
+}
+
+Error StreamPeerExtension::get_partial_data(uint8_t *r_buffer, int p_bytes, int &r_received) {
+ int err;
+ if (GDVIRTUAL_CALL(_get_partial_data, r_buffer, p_bytes, &r_received, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_get_partial_data is unimplemented!");
+ return FAILED;
+}
+
+Error StreamPeerExtension::put_data(const uint8_t *p_data, int p_bytes) {
+ int err;
+ int sent = 0;
+ if (GDVIRTUAL_CALL(_put_data, p_data, p_bytes, &sent, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_put_data is unimplemented!");
+ return FAILED;
+}
+
+Error StreamPeerExtension::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
+ int err;
+ if (GDVIRTUAL_CALL(_put_data, p_data, p_bytes, &r_sent, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("StreamPeerExtension::_put_partial_data is unimplemented!");
+ return FAILED;
+}
+
+void StreamPeerExtension::_bind_methods() {
+ GDVIRTUAL_BIND(_get_data, "r_buffer", "r_bytes", "r_received");
+ GDVIRTUAL_BIND(_get_partial_data, "r_buffer", "r_bytes", "r_received");
+ GDVIRTUAL_BIND(_put_data, "p_data", "p_bytes", "r_sent");
+ GDVIRTUAL_BIND(_put_partial_data, "p_data", "p_bytes", "r_sent");
+ GDVIRTUAL_BIND(_get_available_bytes);
+}
+
+////////////////////////////////
+
void StreamPeerBuffer::_bind_methods() {
ClassDB::bind_method(D_METHOD("seek", "position"), &StreamPeerBuffer::seek);
ClassDB::bind_method(D_METHOD("get_size"), &StreamPeerBuffer::get_size);
diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h
index effc3850af..89432951c5 100644
--- a/core/io/stream_peer.h
+++ b/core/io/stream_peer.h
@@ -33,6 +33,10 @@
#include "core/object/ref_counted.h"
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
class StreamPeer : public RefCounted {
GDCLASS(StreamPeer, RefCounted);
OBJ_CATEGORY("Networking");
@@ -58,6 +62,7 @@ public:
virtual int get_available_bytes() const = 0;
+ /* helpers */
void set_big_endian(bool p_big_endian);
bool is_big_endian_enabled() const;
@@ -92,6 +97,26 @@ public:
StreamPeer() {}
};
+class StreamPeerExtension : public StreamPeer {
+ GDCLASS(StreamPeerExtension, StreamPeer);
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual Error put_data(const uint8_t *p_data, int p_bytes) override;
+ virtual Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) override;
+ virtual Error get_data(uint8_t *p_buffer, int p_bytes) override;
+ virtual Error get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) override;
+ virtual int get_available_bytes() const override;
+
+ GDVIRTUAL3R(int, _put_data, GDNativeConstPtr<const uint8_t>, int, GDNativePtr<int>);
+ GDVIRTUAL3R(int, _put_partial_data, GDNativeConstPtr<const uint8_t>, int, GDNativePtr<int>);
+ GDVIRTUAL3R(int, _get_data, GDNativePtr<uint8_t>, int, GDNativePtr<int>);
+ GDVIRTUAL3R(int, _get_partial_data, GDNativePtr<uint8_t>, int, GDNativePtr<int>);
+ GDVIRTUAL0RC(int, _get_available_bytes);
+};
+
class StreamPeerBuffer : public StreamPeer {
GDCLASS(StreamPeerBuffer, StreamPeer);
diff --git a/core/multiplayer/multiplayer_peer.cpp b/core/multiplayer/multiplayer_peer.cpp
index 40847102d8..3c33948e2f 100644
--- a/core/multiplayer/multiplayer_peer.cpp
+++ b/core/multiplayer/multiplayer_peer.cpp
@@ -53,6 +53,30 @@ uint32_t MultiplayerPeer::generate_unique_id() const {
return hash;
}
+void MultiplayerPeer::set_transfer_channel(int p_channel) {
+ transfer_channel = p_channel;
+}
+
+int MultiplayerPeer::get_transfer_channel() const {
+ return transfer_channel;
+}
+
+void MultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
+ transfer_mode = p_mode;
+}
+
+Multiplayer::TransferMode MultiplayerPeer::get_transfer_mode() const {
+ return transfer_mode;
+}
+
+void MultiplayerPeer::set_refuse_new_connections(bool p_enable) {
+ refuse_connections = p_enable;
+}
+
+bool MultiplayerPeer::is_refusing_new_connections() const {
+ return refuse_connections;
+}
+
void MultiplayerPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_transfer_channel", "channel"), &MultiplayerPeer::set_transfer_channel);
ClassDB::bind_method(D_METHOD("get_transfer_channel"), &MultiplayerPeer::get_transfer_channel);
@@ -88,3 +112,160 @@ void MultiplayerPeer::_bind_methods() {
ADD_SIGNAL(MethodInfo("connection_succeeded"));
ADD_SIGNAL(MethodInfo("connection_failed"));
}
+
+/*************/
+
+int MultiplayerPeerExtension::get_available_packet_count() const {
+ int count;
+ if (GDVIRTUAL_CALL(_get_available_packet_count, count)) {
+ return count;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_available_packet_count is unimplemented!");
+ return -1;
+}
+
+Error MultiplayerPeerExtension::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_get_packet, r_buffer, &r_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_packet_native is unimplemented!");
+ return FAILED;
+}
+
+Error MultiplayerPeerExtension::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_put_packet, p_buffer, p_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_put_packet_native is unimplemented!");
+ return FAILED;
+}
+
+int MultiplayerPeerExtension::get_max_packet_size() const {
+ int size;
+ if (GDVIRTUAL_CALL(_get_max_packet_size, size)) {
+ return size;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_max_packet_size is unimplemented!");
+ return 0;
+}
+
+void MultiplayerPeerExtension::set_transfer_channel(int p_channel) {
+ if (GDVIRTUAL_CALL(_set_transfer_channel, p_channel)) {
+ return;
+ }
+ MultiplayerPeer::set_transfer_channel(p_channel);
+}
+
+int MultiplayerPeerExtension::get_transfer_channel() const {
+ int channel;
+ if (GDVIRTUAL_CALL(_get_transfer_channel, channel)) {
+ return channel;
+ }
+ return MultiplayerPeer::get_transfer_channel();
+}
+
+void MultiplayerPeerExtension::set_transfer_mode(Multiplayer::TransferMode p_mode) {
+ if (GDVIRTUAL_CALL(_set_transfer_mode, p_mode)) {
+ return;
+ }
+ MultiplayerPeer::set_transfer_mode(p_mode);
+}
+
+Multiplayer::TransferMode MultiplayerPeerExtension::get_transfer_mode() const {
+ int mode;
+ if (GDVIRTUAL_CALL(_get_transfer_mode, mode)) {
+ return (Multiplayer::TransferMode)mode;
+ }
+ return MultiplayerPeer::get_transfer_mode();
+}
+
+void MultiplayerPeerExtension::set_target_peer(int p_peer_id) {
+ if (GDVIRTUAL_CALL(_set_target_peer, p_peer_id)) {
+ return;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_set_target_peer is unimplemented!");
+}
+
+int MultiplayerPeerExtension::get_packet_peer() const {
+ int peer;
+ if (GDVIRTUAL_CALL(_get_packet_peer, peer)) {
+ return peer;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_packet_peer is unimplemented!");
+ return 0;
+}
+
+bool MultiplayerPeerExtension::is_server() const {
+ bool server;
+ if (GDVIRTUAL_CALL(_is_server, server)) {
+ return server;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_is_server is unimplemented!");
+ return false;
+}
+
+void MultiplayerPeerExtension::poll() {
+ int err;
+ if (GDVIRTUAL_CALL(_poll, err)) {
+ return;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_poll is unimplemented!");
+}
+
+int MultiplayerPeerExtension::get_unique_id() const {
+ int id;
+ if (GDVIRTUAL_CALL(_get_unique_id, id)) {
+ return id;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_unique_id is unimplemented!");
+ return 0;
+}
+
+void MultiplayerPeerExtension::set_refuse_new_connections(bool p_enable) {
+ if (GDVIRTUAL_CALL(_set_refuse_new_connections, p_enable)) {
+ return;
+ }
+ MultiplayerPeer::set_refuse_new_connections(p_enable);
+}
+
+bool MultiplayerPeerExtension::is_refusing_new_connections() const {
+ bool refusing;
+ if (GDVIRTUAL_CALL(_is_refusing_new_connections, refusing)) {
+ return refusing;
+ }
+ return MultiplayerPeer::is_refusing_new_connections();
+}
+
+MultiplayerPeer::ConnectionStatus MultiplayerPeerExtension::get_connection_status() const {
+ int status;
+ if (GDVIRTUAL_CALL(_get_connection_status, status)) {
+ return (ConnectionStatus)status;
+ }
+ WARN_PRINT_ONCE("MultiplayerPeerExtension::_get_connection_status is unimplemented!");
+ return CONNECTION_DISCONNECTED;
+}
+
+void MultiplayerPeerExtension::_bind_methods() {
+ GDVIRTUAL_BIND(_get_packet, "r_buffer", "r_buffer_size");
+ GDVIRTUAL_BIND(_put_packet, "p_buffer", "p_buffer_size");
+ GDVIRTUAL_BIND(_get_available_packet_count);
+ GDVIRTUAL_BIND(_get_max_packet_size);
+
+ GDVIRTUAL_BIND(_set_transfer_channel, "p_channel");
+ GDVIRTUAL_BIND(_get_transfer_channel);
+
+ GDVIRTUAL_BIND(_set_transfer_mode, "p_mode");
+ GDVIRTUAL_BIND(_get_transfer_mode);
+
+ GDVIRTUAL_BIND(_set_target_peer, "p_peer");
+
+ GDVIRTUAL_BIND(_get_packet_peer);
+ GDVIRTUAL_BIND(_is_server);
+ GDVIRTUAL_BIND(_poll);
+ GDVIRTUAL_BIND(_get_unique_id);
+ GDVIRTUAL_BIND(_set_refuse_new_connections, "p_enable");
+ GDVIRTUAL_BIND(_is_refusing_new_connections);
+ GDVIRTUAL_BIND(_get_connection_status);
+}
diff --git a/core/multiplayer/multiplayer_peer.h b/core/multiplayer/multiplayer_peer.h
index ba00c3b41b..126ba9e645 100644
--- a/core/multiplayer/multiplayer_peer.h
+++ b/core/multiplayer/multiplayer_peer.h
@@ -34,12 +34,21 @@
#include "core/io/packet_peer.h"
#include "core/multiplayer/multiplayer.h"
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
class MultiplayerPeer : public PacketPeer {
GDCLASS(MultiplayerPeer, PacketPeer);
protected:
static void _bind_methods();
+private:
+ int transfer_channel = 0;
+ Multiplayer::TransferMode transfer_mode = Multiplayer::TRANSFER_MODE_RELIABLE;
+ bool refuse_connections = false;
+
public:
enum {
TARGET_PEER_BROADCAST = 0,
@@ -52,10 +61,13 @@ public:
CONNECTION_CONNECTED,
};
- virtual void set_transfer_channel(int p_channel) = 0;
- virtual int get_transfer_channel() const = 0;
- virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) = 0;
- virtual Multiplayer::TransferMode get_transfer_mode() const = 0;
+ virtual void set_transfer_channel(int p_channel);
+ virtual int get_transfer_channel() const;
+ virtual void set_transfer_mode(Multiplayer::TransferMode p_mode);
+ virtual Multiplayer::TransferMode get_transfer_mode() const;
+ virtual void set_refuse_new_connections(bool p_enable);
+ virtual bool is_refusing_new_connections() const;
+
virtual void set_target_peer(int p_peer_id) = 0;
virtual int get_packet_peer() const = 0;
@@ -66,15 +78,67 @@ public:
virtual int get_unique_id() const = 0;
- virtual void set_refuse_new_connections(bool p_enable) = 0;
- virtual bool is_refusing_new_connections() const = 0;
-
virtual ConnectionStatus get_connection_status() const = 0;
+
uint32_t generate_unique_id() const;
MultiplayerPeer() {}
};
-VARIANT_ENUM_CAST(MultiplayerPeer::ConnectionStatus)
+VARIANT_ENUM_CAST(MultiplayerPeer::ConnectionStatus);
+
+class MultiplayerPeerExtension : public MultiplayerPeer {
+ GDCLASS(MultiplayerPeerExtension, MultiplayerPeer);
+
+protected:
+ static void _bind_methods();
+
+public:
+ /* PacketPeer */
+ virtual int get_available_packet_count() const override;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; ///< buffer is GONE after next get_packet
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
+ virtual int get_max_packet_size() const override;
+
+ /* MultiplayerPeer */
+ virtual void set_transfer_channel(int p_channel) override;
+ virtual int get_transfer_channel() const override;
+ virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
+ virtual Multiplayer::TransferMode get_transfer_mode() const override;
+ virtual void set_target_peer(int p_peer_id) override;
+
+ virtual int get_packet_peer() const override;
+
+ virtual bool is_server() const override;
+
+ virtual void poll() override;
+
+ virtual int get_unique_id() const override;
+
+ virtual void set_refuse_new_connections(bool p_enable) override;
+ virtual bool is_refusing_new_connections() const override;
+
+ virtual ConnectionStatus get_connection_status() const override;
+
+ /* PacketPeer GDExtension */
+ GDVIRTUAL0RC(int, _get_available_packet_count);
+ GDVIRTUAL2R(int, _get_packet, GDNativeConstPtr<const uint8_t *>, GDNativePtr<int>);
+ GDVIRTUAL2R(int, _put_packet, GDNativeConstPtr<const uint8_t>, int);
+ GDVIRTUAL0RC(int, _get_max_packet_size);
+
+ /* MultiplayerPeer GDExtension */
+ GDVIRTUAL1(_set_transfer_channel, int);
+ GDVIRTUAL0RC(int, _get_transfer_channel);
+ GDVIRTUAL1(_set_transfer_mode, int);
+ GDVIRTUAL0RC(int, _get_transfer_mode);
+ GDVIRTUAL1(_set_target_peer, int);
+ GDVIRTUAL0RC(int, _get_packet_peer);
+ GDVIRTUAL0RC(bool, _is_server);
+ GDVIRTUAL0R(int, _poll);
+ GDVIRTUAL0RC(int, _get_unique_id);
+ GDVIRTUAL1(_set_refuse_new_connections, bool);
+ GDVIRTUAL0RC(bool, _is_refusing_new_connections);
+ GDVIRTUAL0RC(int, _get_connection_status);
+};
#endif // NETWORKED_MULTIPLAYER_PEER_H
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 3a037f9dd1..e33c21cc00 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -169,11 +169,13 @@ void register_core_types() {
GDREGISTER_VIRTUAL_CLASS(IP);
GDREGISTER_VIRTUAL_CLASS(StreamPeer);
+ GDREGISTER_CLASS(StreamPeerExtension);
GDREGISTER_CLASS(StreamPeerBuffer);
GDREGISTER_CLASS(StreamPeerTCP);
GDREGISTER_CLASS(TCPServer);
GDREGISTER_VIRTUAL_CLASS(PacketPeer);
+ GDREGISTER_CLASS(PacketPeerExtension);
GDREGISTER_CLASS(PacketPeerStream);
GDREGISTER_CLASS(PacketPeerUDP);
GDREGISTER_CLASS(UDPServer);
@@ -197,6 +199,7 @@ void register_core_types() {
ResourceLoader::add_resource_format_loader(resource_format_loader_crypto);
GDREGISTER_VIRTUAL_CLASS(MultiplayerPeer);
+ GDREGISTER_VIRTUAL_CLASS(MultiplayerPeerExtension);
GDREGISTER_VIRTUAL_CLASS(MultiplayerReplicator);
GDREGISTER_CLASS(MultiplayerAPI);
GDREGISTER_CLASS(MainLoop);
diff --git a/core/variant/native_ptr.h b/core/variant/native_ptr.h
index b4ec0df7d6..b7e8d92f62 100644
--- a/core/variant/native_ptr.h
+++ b/core/variant/native_ptr.h
@@ -117,6 +117,7 @@ GDVIRTUAL_NATIVE_PTR(char16_t)
GDVIRTUAL_NATIVE_PTR(char32_t)
GDVIRTUAL_NATIVE_PTR(wchar_t)
GDVIRTUAL_NATIVE_PTR(uint8_t)
+GDVIRTUAL_NATIVE_PTR(uint8_t *)
GDVIRTUAL_NATIVE_PTR(int8_t)
GDVIRTUAL_NATIVE_PTR(uint16_t)
GDVIRTUAL_NATIVE_PTR(int16_t)
diff --git a/doc/classes/MultiplayerPeer.xml b/doc/classes/MultiplayerPeer.xml
index a9c2a941f8..15517f7c2f 100644
--- a/doc/classes/MultiplayerPeer.xml
+++ b/doc/classes/MultiplayerPeer.xml
@@ -53,14 +53,14 @@
</method>
</methods>
<members>
- <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" default="true">
+ <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" default="false">
If [code]true[/code], this [MultiplayerPeer] refuses new connections.
</member>
<member name="transfer_channel" type="int" setter="set_transfer_channel" getter="get_transfer_channel" default="0">
The channel to use to send packets. Many network APIs such as ENet and WebRTC allow the creation of multiple independent channels which behaves, in a way, like separate connections. This means that reliable data will only block delivery of other packets on that channel, and ordering will only be in respect to the channel the packet is being sent on. Using different channels to send [b]different and independent[/b] state updates is a common way to optimize network usage and decrease latency in fast-paced games.
[b]Note:[/b] The default channel ([code]0[/code]) actually works as 3 separate channels (one for each [enum TransferMode]) so that [constant TRANSFER_MODE_RELIABLE] and [constant TRANSFER_MODE_ORDERED] does not interact with each other by default. Refer to the specific network API documentation (e.g. ENet or WebRTC) to learn how to set up channels correctly.
</member>
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" enum="TransferMode" default="0">
+ <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" enum="TransferMode" default="2">
The manner in which to send packets to the [code]target_peer[/code]. See [enum TransferMode].
</member>
</members>
diff --git a/doc/classes/MultiplayerPeerExtension.xml b/doc/classes/MultiplayerPeerExtension.xml
new file mode 100644
index 0000000000..d9c173a4a1
--- /dev/null
+++ b/doc/classes/MultiplayerPeerExtension.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="MultiplayerPeerExtension" inherits="MultiplayerPeer" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_get_available_packet_count" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_connection_status" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_packet_size" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="const void*" />
+ <argument index="1" name="r_buffer_size" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_packet_peer" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_transfer_channel" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_transfer_mode" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_unique_id" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_is_refusing_new_connections" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_is_server" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_poll" qualifiers="virtual">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_buffer" type="const void*" />
+ <argument index="1" name="p_buffer_size" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_refuse_new_connections" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_enable" type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_target_peer" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_peer" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_transfer_channel" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_channel" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_transfer_mode" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_mode" type="int" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/doc/classes/PacketPeerExtension.xml b/doc/classes/PacketPeerExtension.xml
new file mode 100644
index 0000000000..6804053484
--- /dev/null
+++ b/doc/classes/PacketPeerExtension.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="PacketPeerExtension" inherits="PacketPeer" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_get_available_packet_count" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_packet_size" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="const void*" />
+ <argument index="1" name="r_buffer_size" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_buffer" type="const void*" />
+ <argument index="1" name="p_buffer_size" type="int" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/doc/classes/StreamPeerExtension.xml b/doc/classes/StreamPeerExtension.xml
new file mode 100644
index 0000000000..93fda8cf5d
--- /dev/null
+++ b/doc/classes/StreamPeerExtension.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="StreamPeerExtension" inherits="StreamPeer" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_get_available_bytes" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_data" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="uint8_t*" />
+ <argument index="1" name="r_bytes" type="int" />
+ <argument index="2" name="r_received" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_partial_data" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="uint8_t*" />
+ <argument index="1" name="r_bytes" type="int" />
+ <argument index="2" name="r_received" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_data" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_data" type="const void*" />
+ <argument index="1" name="p_bytes" type="int" />
+ <argument index="2" name="r_sent" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_partial_data" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_data" type="const void*" />
+ <argument index="1" name="p_bytes" type="int" />
+ <argument index="2" name="r_sent" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/modules/enet/doc_classes/ENetMultiplayerPeer.xml b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
index 456b390dbb..f9659c092a 100644
--- a/modules/enet/doc_classes/ENetMultiplayerPeer.xml
+++ b/modules/enet/doc_classes/ENetMultiplayerPeer.xml
@@ -77,10 +77,8 @@
<member name="host" type="ENetConnection" setter="" getter="get_host">
The underlying [ENetConnection] created after [method create_client] and [method create_server].
</member>
- <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
<member name="server_relay" type="bool" setter="set_server_relay_enabled" getter="is_server_relay_enabled" default="true">
Enable or disable the server feature that notifies clients of other peers' connection/disconnection, and relays messages between them. When this option is [code]false[/code], clients won't be automatically notified of other peers and won't be able to send them packets through the server.
</member>
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="TransferMode" default="2" />
</members>
</class>
diff --git a/modules/enet/enet_multiplayer_peer.cpp b/modules/enet/enet_multiplayer_peer.cpp
index 5bdc93dc78..52eb46f070 100644
--- a/modules/enet/enet_multiplayer_peer.cpp
+++ b/modules/enet/enet_multiplayer_peer.cpp
@@ -33,22 +33,6 @@
#include "core/io/marshalls.h"
#include "core/os/os.h"
-void ENetMultiplayerPeer::set_transfer_channel(int p_channel) {
- transfer_channel = p_channel;
-}
-
-int ENetMultiplayerPeer::get_transfer_channel() const {
- return transfer_channel;
-}
-
-void ENetMultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
- transfer_mode = p_mode;
-}
-
-Multiplayer::TransferMode ENetMultiplayerPeer::get_transfer_mode() const {
- return transfer_mode;
-}
-
void ENetMultiplayerPeer::set_target_peer(int p_peer) {
target_peer = p_peer;
}
@@ -62,6 +46,7 @@ int ENetMultiplayerPeer::get_packet_peer() const {
Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_max_channels, int p_in_bandwidth, int p_out_bandwidth) {
ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
+ set_refuse_new_connections(false);
Ref<ENetConnection> host;
host.instantiate();
Error err = host->create_host_bound(bind_ip, p_port, p_max_clients, 0, p_max_channels > 0 ? p_max_channels + SYSCH_MAX : 0, p_out_bandwidth);
@@ -70,7 +55,6 @@ Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_ma
}
active_mode = MODE_SERVER;
- refuse_connections = false;
unique_id = 1;
connection_status = CONNECTION_CONNECTED;
hosts[0] = host;
@@ -79,6 +63,7 @@ Error ENetMultiplayerPeer::create_server(int p_port, int p_max_clients, int p_ma
Error ENetMultiplayerPeer::create_client(const String &p_address, int p_port, int p_channel_count, int p_in_bandwidth, int p_out_bandwidth, int p_local_port) {
ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
+ set_refuse_new_connections(false);
Ref<ENetConnection> host;
host.instantiate();
Error err;
@@ -102,7 +87,6 @@ Error ENetMultiplayerPeer::create_client(const String &p_address, int p_port, in
// Need to wait for CONNECT event.
connection_status = CONNECTION_CONNECTING;
active_mode = MODE_CLIENT;
- refuse_connections = false;
peers[1] = peer;
hosts[0] = host;
@@ -113,7 +97,6 @@ Error ENetMultiplayerPeer::create_mesh(int p_id) {
ERR_FAIL_COND_V_MSG(p_id <= 0, ERR_INVALID_PARAMETER, "The unique ID must be greater then 0");
ERR_FAIL_COND_V_MSG(_is_active(), ERR_ALREADY_IN_USE, "The multiplayer instance is already active.");
active_mode = MODE_MESH;
- refuse_connections = false;
unique_id = p_id;
connection_status = CONNECTION_CONNECTED;
return OK;
@@ -145,7 +128,7 @@ bool ENetMultiplayerPeer::_poll_server() {
}
switch (ret) {
case ENetConnection::EVENT_CONNECT: {
- if (refuse_connections) {
+ if (is_refusing_new_connections()) {
event.peer->reset();
return false;
}
@@ -423,6 +406,7 @@ void ENetMultiplayerPeer::close_connection(uint32_t wait_usec) {
hosts.clear();
unique_id = 0;
connection_status = CONNECTION_DISCONNECTED;
+ set_refuse_new_connections(false);
}
int ENetMultiplayerPeer::get_available_packet_count() const {
@@ -451,10 +435,11 @@ Error ENetMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size
int packet_flags = 0;
int channel = SYSCH_RELIABLE;
+ int transfer_channel = get_transfer_channel();
if (transfer_channel > 0) {
channel = SYSCH_MAX + transfer_channel - 1;
} else {
- switch (transfer_mode) {
+ switch (get_transfer_mode()) {
case Multiplayer::TRANSFER_MODE_UNRELIABLE: {
packet_flags = ENET_PACKET_FLAG_UNSEQUENCED;
channel = SYSCH_UNRELIABLE;
@@ -545,19 +530,15 @@ int ENetMultiplayerPeer::get_unique_id() const {
return unique_id;
}
-void ENetMultiplayerPeer::set_refuse_new_connections(bool p_enable) {
- refuse_connections = p_enable;
+void ENetMultiplayerPeer::set_refuse_new_connections(bool p_enabled) {
#ifdef GODOT_ENET
if (_is_active()) {
for (KeyValue<int, Ref<ENetConnection>> &E : hosts) {
- E.value->refuse_new_connections(p_enable);
+ E.value->refuse_new_connections(p_enabled);
}
}
#endif
-}
-
-bool ENetMultiplayerPeer::is_refusing_new_connections() const {
- return refuse_connections;
+ MultiplayerPeer::set_refuse_new_connections(p_enabled);
}
void ENetMultiplayerPeer::set_server_relay_enabled(bool p_enabled) {
diff --git a/modules/enet/enet_multiplayer_peer.h b/modules/enet/enet_multiplayer_peer.h
index b5316b8292..7a60e2359c 100644
--- a/modules/enet/enet_multiplayer_peer.h
+++ b/modules/enet/enet_multiplayer_peer.h
@@ -65,10 +65,7 @@ private:
uint32_t unique_id = 0;
int target_peer = 0;
- int transfer_channel = 0;
- Multiplayer::TransferMode transfer_mode = Multiplayer::TRANSFER_MODE_RELIABLE;
- bool refuse_connections = false;
bool server_relay = true;
ConnectionStatus connection_status = CONNECTION_DISCONNECTED;
@@ -101,40 +98,31 @@ protected:
static void _bind_methods();
public:
- virtual void set_transfer_channel(int p_channel) override;
- virtual int get_transfer_channel() const override;
-
- virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
- virtual Multiplayer::TransferMode get_transfer_mode() const override;
virtual void set_target_peer(int p_peer) override;
-
virtual int get_packet_peer() const override;
- Error create_server(int p_port, int p_max_clients = 32, int p_max_channels = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0);
- Error create_client(const String &p_address, int p_port, int p_channel_count = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0, int p_local_port = 0);
- Error create_mesh(int p_id);
- Error add_mesh_peer(int p_id, Ref<ENetConnection> p_host);
-
- void close_connection(uint32_t wait_usec = 100);
-
- void disconnect_peer(int p_peer, bool now = false);
-
virtual void poll() override;
-
virtual bool is_server() const override;
+ // Overriden so we can instrument the DTLSServer when needed.
+ virtual void set_refuse_new_connections(bool p_enabled) override;
- virtual int get_available_packet_count() const override;
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override; ///< buffer is GONE after next get_packet
- virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
+ virtual ConnectionStatus get_connection_status() const override;
+
+ virtual int get_unique_id() const override;
virtual int get_max_packet_size() const override;
+ virtual int get_available_packet_count() const override;
+ virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override;
+ virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
- virtual ConnectionStatus get_connection_status() const override;
+ Error create_server(int p_port, int p_max_clients = 32, int p_max_channels = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0);
+ Error create_client(const String &p_address, int p_port, int p_channel_count = 0, int p_in_bandwidth = 0, int p_out_bandwidth = 0, int p_local_port = 0);
+ Error create_mesh(int p_id);
+ Error add_mesh_peer(int p_id, Ref<ENetConnection> p_host);
- virtual void set_refuse_new_connections(bool p_enable) override;
- virtual bool is_refusing_new_connections() const override;
+ void close_connection(uint32_t wait_usec = 100);
- virtual int get_unique_id() const override;
+ void disconnect_peer(int p_peer, bool now = false);
void set_bind_ip(const IPAddress &p_ip);
void set_server_relay_enabled(bool p_enabled);
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index 21ee39f3ed..94bda04d12 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -16,7 +16,6 @@ env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"])
Export("env_gdnative")
-SConscript("net/SCsub")
SConscript("pluginscript/SCsub")
SConscript("videodecoder/SCsub")
SConscript("text/SCsub")
diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py
index fa985501b5..026a84a70f 100644
--- a/modules/gdnative/config.py
+++ b/modules/gdnative/config.py
@@ -10,14 +10,9 @@ def get_doc_classes():
return [
"GDNative",
"GDNativeLibrary",
- "MultiplayerPeerGDNative",
"NativeScript",
- "PacketPeerGDNative",
"PluginScript",
- "StreamPeerGDNative",
"VideoStreamGDNative",
- "WebRTCPeerConnectionGDNative",
- "WebRTCDataChannelGDNative",
]
diff --git a/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml b/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml
deleted file mode 100644
index 40f3121525..0000000000
--- a/modules/gdnative/doc_classes/MultiplayerPeerGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="MultiplayerPeerGDNative" inherits="MultiplayerPeer" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/doc_classes/PacketPeerGDNative.xml b/modules/gdnative/doc_classes/PacketPeerGDNative.xml
deleted file mode 100644
index 32863f8422..0000000000
--- a/modules/gdnative/doc_classes/PacketPeerGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="PacketPeerGDNative" inherits="PacketPeer" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/doc_classes/StreamPeerGDNative.xml b/modules/gdnative/doc_classes/StreamPeerGDNative.xml
deleted file mode 100644
index a505de2106..0000000000
--- a/modules/gdnative/doc_classes/StreamPeerGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="StreamPeerGDNative" inherits="StreamPeer" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml b/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml
deleted file mode 100644
index ddf354763c..0000000000
--- a/modules/gdnative/doc_classes/WebRTCDataChannelGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebRTCDataChannelGDNative" inherits="WebRTCDataChannel" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml b/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml
deleted file mode 100644
index 821779a0ff..0000000000
--- a/modules/gdnative/doc_classes/WebRTCPeerConnectionGDNative.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="WebRTCPeerConnectionGDNative" inherits="WebRTCPeerConnection" version="4.0">
- <brief_description>
- </brief_description>
- <description>
- </description>
- <tutorials>
- </tutorials>
-</class>
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 66d2dc267d..627883886c 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -5105,97 +5105,6 @@
]
},
{
- "name": "net",
- "type": "NET",
- "version": {
- "major": 4,
- "minor": 0
- },
- "next": null,
- "api": [
- {
- "name": "godot_net_bind_stream_peer",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_stream_peer *",
- "p_interface"
- ]
- ]
- },
- {
- "name": "godot_net_bind_packet_peer",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_packet_peer *",
- "p_interface"
- ]
- ]
- },
- {
- "name": "godot_net_bind_multiplayer_peer",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_multiplayer_peer *",
- "p_interface"
- ]
- ]
- },
- {
- "name": "godot_net_set_webrtc_library",
- "return_type": "godot_error",
- "arguments": [
- [
- "const godot_net_webrtc_library *",
- "p_library"
- ]
- ]
- },
- {
- "name": "godot_net_bind_webrtc_peer_connection",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_webrtc_peer_connection *",
- "p_interface"
- ]
- ]
- },
- {
- "name": "godot_net_bind_webrtc_data_channel",
- "return_type": "void",
- "arguments": [
- [
- "godot_object *",
- "p_obj"
- ],
- [
- "const godot_net_webrtc_data_channel *",
- "p_interface"
- ]
- ]
- }
- ]
- },
- {
"name": "text",
"type": "TEXT",
"version": {
diff --git a/modules/gdnative/gdnative_builders.py b/modules/gdnative/gdnative_builders.py
index 181fd71b82..4986b173cf 100644
--- a/modules/gdnative/gdnative_builders.py
+++ b/modules/gdnative/gdnative_builders.py
@@ -20,7 +20,6 @@ def _build_gdnative_api_struct_header(api):
"#include <gdnative/gdnative.h>",
"#include <android/godot_android.h>",
"#include <nativescript/godot_nativescript.h>",
- "#include <net/godot_net.h>",
"#include <pluginscript/godot_pluginscript.h>",
"#include <videodecoder/godot_videodecoder.h>",
"#include <text/godot_text.h>",
diff --git a/modules/gdnative/include/net/godot_net.h b/modules/gdnative/include/net/godot_net.h
deleted file mode 100644
index 3fb7b9e1cc..0000000000
--- a/modules/gdnative/include/net/godot_net.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*************************************************************************/
-/* godot_net.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef GODOT_NATIVENET_H
-#define GODOT_NATIVENET_H
-
-#include <gdnative/gdnative.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-// For future versions of the API we should only add new functions at the end of the structure and use the
-// version info to detect whether a call is available
-
-// Use these to populate version in your plugin
-#define GODOT_NET_API_MAJOR 3
-#define GODOT_NET_API_MINOR 1
-
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
- godot_object *data; /* User reference */
-
- /* This is StreamPeer */
- godot_error (*get_data)(void *user, uint8_t *p_buffer, int p_bytes);
- godot_error (*get_partial_data)(void *user, uint8_t *p_buffer, int p_bytes, int *r_received);
- godot_error (*put_data)(void *user, const uint8_t *p_data, int p_bytes);
- godot_error (*put_partial_data)(void *user, const uint8_t *p_data, int p_bytes, int *r_sent);
-
- int (*get_available_bytes)(const void *user);
-
- void *next; /* For extension? */
-} godot_net_stream_peer;
-
-/* Binds a StreamPeerGDNative to the provided interface */
-void godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface);
-
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- godot_object *data; /* User reference */
-
- /* This is PacketPeer */
- godot_error (*get_packet)(void *, const uint8_t **, int *);
- godot_error (*put_packet)(void *, const uint8_t *, int);
- godot_int (*get_available_packet_count)(const void *);
- godot_int (*get_max_packet_size)(const void *);
-
- void *next; /* For extension? */
-} godot_net_packet_peer;
-
-/* Binds a PacketPeerGDNative to the provided interface */
-void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *);
-
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- godot_object *data; /* User reference */
-
- /* This is PacketPeer */
- godot_error (*get_packet)(void *, const uint8_t **, int *);
- godot_error (*put_packet)(void *, const uint8_t *, int);
- godot_int (*get_available_packet_count)(const void *);
- godot_int (*get_max_packet_size)(const void *);
-
- /* This is MultiplayerPeer */
- void (*set_transfer_channel)(void *, godot_int);
- godot_int (*get_transfer_channel)(void *);
- void (*set_transfer_mode)(void *, godot_int);
- godot_int (*get_transfer_mode)(const void *);
- // 0 = broadcast, 1 = server, <0 = all but abs(value)
- void (*set_target_peer)(void *, godot_int);
- godot_int (*get_packet_peer)(const void *);
- godot_bool (*is_server)(const void *);
- void (*poll)(void *);
- // Must be > 0, 1 is for server
- int32_t (*get_unique_id)(const void *);
- void (*set_refuse_new_connections)(void *, godot_bool);
- godot_bool (*is_refusing_new_connections)(const void *);
- godot_int (*get_connection_status)(const void *);
-
- void *next; /* For extension? Or maybe not... */
-} godot_net_multiplayer_peer;
-
-/* Binds a MultiplayerPeerGDNative to the provided interface */
-void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *);
-
-#ifdef __cplusplus
-}
-#endif
-
-// WebRTC Bindings
-#include "net/godot_webrtc.h"
-
-#endif /* GODOT_NATIVENET_H */
diff --git a/modules/gdnative/include/net/godot_webrtc.h b/modules/gdnative/include/net/godot_webrtc.h
deleted file mode 100644
index 52006e56ec..0000000000
--- a/modules/gdnative/include/net/godot_webrtc.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*************************************************************************/
-/* godot_webrtc.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef GODOT_NATIVEWEBRTC_H
-#define GODOT_NATIVEWEBRTC_H
-
-#include <gdnative/gdnative.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define GODOT_NET_WEBRTC_API_MAJOR 4
-#define GODOT_NET_WEBRTC_API_MINOR 0
-
-/* Library Interface (used to set default GDNative WebRTC implementation */
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- /* Called when the library is unset as default interface via godot_net_set_webrtc_library */
- void (*unregistered)();
-
- /* Used by WebRTCPeerConnection create when GDNative is the default implementation. */
- /* Takes a pointer to WebRTCPeerConnectionGDNative, should bind and return OK, failure if binding was unsuccessful. */
- godot_error (*create_peer_connection)(godot_object *);
-
- void *next; /* For extension */
-} godot_net_webrtc_library;
-
-/* WebRTCPeerConnection interface */
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- godot_object *data; /* User reference */
-
- /* This is WebRTCPeerConnection */
- godot_int (*get_connection_state)(const void *);
-
- godot_error (*initialize)(void *, const godot_dictionary *);
- godot_object *(*create_data_channel)(void *, const char *p_channel_name, const godot_dictionary *);
- godot_error (*create_offer)(void *);
- godot_error (*create_answer)(void *); /* unused for now, should be done automatically on set_local_description */
- godot_error (*set_remote_description)(void *, const char *, const char *);
- godot_error (*set_local_description)(void *, const char *, const char *);
- godot_error (*add_ice_candidate)(void *, const char *, int, const char *);
- godot_error (*poll)(void *);
- void (*close)(void *);
-
- void *next; /* For extension? */
-} godot_net_webrtc_peer_connection;
-
-/* WebRTCDataChannel interface */
-typedef struct {
- godot_gdnative_api_version version; /* version of our API */
-
- godot_object *data; /* User reference */
-
- /* This is PacketPeer */
- godot_error (*get_packet)(void *, const uint8_t **, int *);
- godot_error (*put_packet)(void *, const uint8_t *, int);
- godot_int (*get_available_packet_count)(const void *);
- godot_int (*get_max_packet_size)(const void *);
-
- /* This is WebRTCDataChannel */
- void (*set_write_mode)(void *, godot_int);
- godot_int (*get_write_mode)(const void *);
- bool (*was_string_packet)(const void *);
-
- godot_int (*get_ready_state)(const void *);
- const char *(*get_label)(const void *);
- bool (*is_ordered)(const void *);
- int (*get_id)(const void *);
- int (*get_max_packet_life_time)(const void *);
- int (*get_max_retransmits)(const void *);
- const char *(*get_protocol)(const void *);
- bool (*is_negotiated)(const void *);
- int (*get_buffered_amount)(const void *);
-
- godot_error (*poll)(void *);
- void (*close)(void *);
-
- void *next; /* For extension? */
-} godot_net_webrtc_data_channel;
-
-/* Set the default GDNative library */
-godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *);
-/* Binds a WebRTCPeerConnectionGDNative to the provided interface */
-void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *);
-/* Binds a WebRTCDataChannelGDNative to the provided interface */
-void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/modules/gdnative/net/SCsub b/modules/gdnative/net/SCsub
deleted file mode 100644
index b76500c003..0000000000
--- a/modules/gdnative/net/SCsub
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env python
-
-Import("env")
-Import("env_gdnative")
-
-env_net = env_gdnative.Clone()
-
-has_webrtc = env_net["module_webrtc_enabled"]
-if has_webrtc:
- env_net.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"])
-
-env_net.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.cpp b/modules/gdnative/net/multiplayer_peer_gdnative.cpp
deleted file mode 100644
index 575d5f5060..0000000000
--- a/modules/gdnative/net/multiplayer_peer_gdnative.cpp
+++ /dev/null
@@ -1,136 +0,0 @@
-/*************************************************************************/
-/* multiplayer_peer_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "multiplayer_peer_gdnative.h"
-
-MultiplayerPeerGDNative::MultiplayerPeerGDNative() {
- interface = nullptr;
-}
-
-MultiplayerPeerGDNative::~MultiplayerPeerGDNative() {
-}
-
-void MultiplayerPeerGDNative::set_native_multiplayer_peer(const godot_net_multiplayer_peer *p_interface) {
- interface = p_interface;
-}
-
-Error MultiplayerPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
-}
-
-Error MultiplayerPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
-}
-
-int MultiplayerPeerGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_max_packet_size(interface->data);
-}
-
-int MultiplayerPeerGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_available_packet_count(interface->data);
-}
-
-/* MultiplayerPeer */
-void MultiplayerPeerGDNative::set_transfer_channel(int p_channel) {
- ERR_FAIL_COND(interface == nullptr);
- return interface->set_transfer_channel(interface->data, p_channel);
-}
-
-int MultiplayerPeerGDNative::get_transfer_channel() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_transfer_channel(interface->data);
-}
-
-void MultiplayerPeerGDNative::set_transfer_mode(Multiplayer::TransferMode p_mode) {
- ERR_FAIL_COND(interface == nullptr);
- interface->set_transfer_mode(interface->data, (godot_int)p_mode);
-}
-
-Multiplayer::TransferMode MultiplayerPeerGDNative::get_transfer_mode() const {
- ERR_FAIL_COND_V(interface == nullptr, Multiplayer::TRANSFER_MODE_UNRELIABLE);
- return (Multiplayer::TransferMode)interface->get_transfer_mode(interface->data);
-}
-
-void MultiplayerPeerGDNative::set_target_peer(int p_peer_id) {
- ERR_FAIL_COND(interface == nullptr);
- interface->set_target_peer(interface->data, p_peer_id);
-}
-
-int MultiplayerPeerGDNative::get_packet_peer() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_packet_peer(interface->data);
-}
-
-bool MultiplayerPeerGDNative::is_server() const {
- ERR_FAIL_COND_V(interface == nullptr, false);
- return interface->is_server(interface->data);
-}
-
-void MultiplayerPeerGDNative::poll() {
- ERR_FAIL_COND(interface == nullptr);
- interface->poll(interface->data);
-}
-
-int MultiplayerPeerGDNative::get_unique_id() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_unique_id(interface->data);
-}
-
-void MultiplayerPeerGDNative::set_refuse_new_connections(bool p_enable) {
- ERR_FAIL_COND(interface == nullptr);
- interface->set_refuse_new_connections(interface->data, p_enable);
-}
-
-bool MultiplayerPeerGDNative::is_refusing_new_connections() const {
- ERR_FAIL_COND_V(interface == nullptr, true);
- return interface->is_refusing_new_connections(interface->data);
-}
-
-MultiplayerPeer::ConnectionStatus MultiplayerPeerGDNative::get_connection_status() const {
- ERR_FAIL_COND_V(interface == nullptr, CONNECTION_DISCONNECTED);
- return (ConnectionStatus)interface->get_connection_status(interface->data);
-}
-
-void MultiplayerPeerGDNative::_bind_methods() {
- ADD_PROPERTY_DEFAULT("transfer_channel", 0);
- ADD_PROPERTY_DEFAULT("transfer_mode", Multiplayer::TRANSFER_MODE_UNRELIABLE);
- ADD_PROPERTY_DEFAULT("refuse_new_connections", true);
-}
-
-extern "C" {
-
-void GDAPI godot_net_bind_multiplayer_peer(godot_object *p_obj, const godot_net_multiplayer_peer *p_impl) {
- ((MultiplayerPeerGDNative *)p_obj)->set_native_multiplayer_peer(p_impl);
-}
-}
diff --git a/modules/gdnative/net/multiplayer_peer_gdnative.h b/modules/gdnative/net/multiplayer_peer_gdnative.h
deleted file mode 100644
index 33e424d284..0000000000
--- a/modules/gdnative/net/multiplayer_peer_gdnative.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*************************************************************************/
-/* multiplayer_peer_gdnative.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef MULTIPLAYER_PEER_GDNATIVE_H
-#define MULTIPLAYER_PEER_GDNATIVE_H
-
-#include "core/multiplayer/multiplayer_peer.h"
-#include "modules/gdnative/gdnative.h"
-#include "modules/gdnative/include/net/godot_net.h"
-
-class MultiplayerPeerGDNative : public MultiplayerPeer {
- GDCLASS(MultiplayerPeerGDNative, MultiplayerPeer);
-
-protected:
- static void _bind_methods();
- const godot_net_multiplayer_peer *interface;
-
-public:
- MultiplayerPeerGDNative();
- ~MultiplayerPeerGDNative();
-
- /* Sets the interface implementation from GDNative */
- void set_native_multiplayer_peer(const godot_net_multiplayer_peer *p_impl);
-
- /* Specific to PacketPeer */
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override;
- virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
- virtual int get_max_packet_size() const override;
- virtual int get_available_packet_count() const override;
-
- /* Specific to MultiplayerPeer */
- virtual void set_transfer_channel(int p_channel) override;
- virtual int get_transfer_channel() const override;
- virtual void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
- virtual Multiplayer::TransferMode get_transfer_mode() const override;
- virtual void set_target_peer(int p_peer_id) override;
-
- virtual int get_packet_peer() const override;
-
- virtual bool is_server() const override;
-
- virtual void poll() override;
-
- virtual int get_unique_id() const override;
-
- virtual void set_refuse_new_connections(bool p_enable) override;
- virtual bool is_refusing_new_connections() const override;
-
- virtual ConnectionStatus get_connection_status() const override;
-};
-
-#endif // MULTIPLAYER_PEER_GDNATIVE_H
diff --git a/modules/gdnative/net/packet_peer_gdnative.cpp b/modules/gdnative/net/packet_peer_gdnative.cpp
deleted file mode 100644
index 3bcdfed8ff..0000000000
--- a/modules/gdnative/net/packet_peer_gdnative.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/*************************************************************************/
-/* packet_peer_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "packet_peer_gdnative.h"
-
-PacketPeerGDNative::PacketPeerGDNative() {
- interface = nullptr;
-}
-
-PacketPeerGDNative::~PacketPeerGDNative() {
-}
-
-void PacketPeerGDNative::set_native_packet_peer(const godot_net_packet_peer *p_impl) {
- interface = p_impl;
-}
-
-void PacketPeerGDNative::_bind_methods() {
-}
-
-Error PacketPeerGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
-}
-
-Error PacketPeerGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
-}
-
-int PacketPeerGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_max_packet_size(interface->data);
-}
-
-int PacketPeerGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_available_packet_count(interface->data);
-}
-
-extern "C" {
-
-void GDAPI godot_net_bind_packet_peer(godot_object *p_obj, const godot_net_packet_peer *p_impl) {
- ((PacketPeerGDNative *)p_obj)->set_native_packet_peer(p_impl);
-}
-}
diff --git a/modules/gdnative/net/packet_peer_gdnative.h b/modules/gdnative/net/packet_peer_gdnative.h
deleted file mode 100644
index 29013f9367..0000000000
--- a/modules/gdnative/net/packet_peer_gdnative.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*************************************************************************/
-/* packet_peer_gdnative.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef PACKET_PEER_GDNATIVE_H
-#define PACKET_PEER_GDNATIVE_H
-
-#include "core/io/packet_peer.h"
-#include "modules/gdnative/gdnative.h"
-#include "modules/gdnative/include/net/godot_net.h"
-
-class PacketPeerGDNative : public PacketPeer {
- GDCLASS(PacketPeerGDNative, PacketPeer);
-
-protected:
- static void _bind_methods();
- const godot_net_packet_peer *interface;
-
-public:
- PacketPeerGDNative();
- ~PacketPeerGDNative();
-
- /* Sets the interface implementation from GDNative */
- void set_native_packet_peer(const godot_net_packet_peer *p_impl);
-
- /* Specific to PacketPeer */
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size) override;
- virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size) override;
- virtual int get_max_packet_size() const override;
- virtual int get_available_packet_count() const override;
-};
-
-#endif // PACKET_PEER_GDNATIVE_H
diff --git a/modules/gdnative/net/register_types.cpp b/modules/gdnative/net/register_types.cpp
deleted file mode 100644
index 46c383e5ae..0000000000
--- a/modules/gdnative/net/register_types.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*************************************************************************/
-/* register_types.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "register_types.h"
-#include "multiplayer_peer_gdnative.h"
-#include "packet_peer_gdnative.h"
-#include "stream_peer_gdnative.h"
-
-void register_net_types() {
- GDREGISTER_CLASS(MultiplayerPeerGDNative);
- GDREGISTER_CLASS(PacketPeerGDNative);
- GDREGISTER_CLASS(StreamPeerGDNative);
-}
-
-void unregister_net_types() {
-}
diff --git a/modules/gdnative/net/register_types.h b/modules/gdnative/net/register_types.h
deleted file mode 100644
index c99c6f6fbf..0000000000
--- a/modules/gdnative/net/register_types.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*************************************************************************/
-/* register_types.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef NET_REGISTER_TYPES_H
-#define NET_REGISTER_TYPES_H
-
-void register_net_types();
-void unregister_net_types();
-
-#endif // NET_REGISTER_TYPES_H
diff --git a/modules/gdnative/net/stream_peer_gdnative.cpp b/modules/gdnative/net/stream_peer_gdnative.cpp
deleted file mode 100644
index 72ab72323d..0000000000
--- a/modules/gdnative/net/stream_peer_gdnative.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/*************************************************************************/
-/* stream_peer_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "stream_peer_gdnative.h"
-
-StreamPeerGDNative::StreamPeerGDNative() {
- interface = nullptr;
-}
-
-StreamPeerGDNative::~StreamPeerGDNative() {
-}
-
-void StreamPeerGDNative::set_native_stream_peer(const godot_net_stream_peer *p_interface) {
- interface = p_interface;
-}
-
-void StreamPeerGDNative::_bind_methods() {
-}
-
-Error StreamPeerGDNative::put_data(const uint8_t *p_data, int p_bytes) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)(interface->put_data(interface->data, p_data, p_bytes));
-}
-
-Error StreamPeerGDNative::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)(interface->put_partial_data(interface->data, p_data, p_bytes, &r_sent));
-}
-
-Error StreamPeerGDNative::get_data(uint8_t *p_buffer, int p_bytes) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)(interface->get_data(interface->data, p_buffer, p_bytes));
-}
-
-Error StreamPeerGDNative::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)(interface->get_partial_data(interface->data, p_buffer, p_bytes, &r_received));
-}
-
-int StreamPeerGDNative::get_available_bytes() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_available_bytes(interface->data);
-}
-
-extern "C" {
-
-void GDAPI godot_net_bind_stream_peer(godot_object *p_obj, const godot_net_stream_peer *p_interface) {
- ((StreamPeerGDNative *)p_obj)->set_native_stream_peer(p_interface);
-}
-}
diff --git a/modules/gdnative/net/stream_peer_gdnative.h b/modules/gdnative/net/stream_peer_gdnative.h
deleted file mode 100644
index dd5abceb83..0000000000
--- a/modules/gdnative/net/stream_peer_gdnative.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*************************************************************************/
-/* stream_peer_gdnative.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifndef STREAM_PEER_GDNATIVE_H
-#define STREAM_PEER_GDNATIVE_H
-
-#include "core/io/stream_peer.h"
-#include "modules/gdnative/gdnative.h"
-#include "modules/gdnative/include/net/godot_net.h"
-
-class StreamPeerGDNative : public StreamPeer {
- GDCLASS(StreamPeerGDNative, StreamPeer);
-
-protected:
- static void _bind_methods();
- const godot_net_stream_peer *interface;
-
-public:
- StreamPeerGDNative();
- ~StreamPeerGDNative();
-
- /* Sets the interface implementation from GDNative */
- void set_native_stream_peer(const godot_net_stream_peer *p_interface);
-
- /* Specific to StreamPeer */
- Error put_data(const uint8_t *p_data, int p_bytes) override;
- Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) override;
- Error get_data(uint8_t *p_buffer, int p_bytes) override;
- Error get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_received) override;
- int get_available_bytes() const override;
-};
-
-#endif // STREAM_PEER_GDNATIVE_H
diff --git a/modules/gdnative/net/webrtc_gdnative.cpp b/modules/gdnative/net/webrtc_gdnative.cpp
deleted file mode 100644
index 76ccbad009..0000000000
--- a/modules/gdnative/net/webrtc_gdnative.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*************************************************************************/
-/* webrtc_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#include "modules/gdnative/gdnative.h"
-#include "modules/gdnative/include/net/godot_net.h"
-
-#ifdef WEBRTC_GDNATIVE_ENABLED
-#include "modules/webrtc/webrtc_data_channel_gdnative.h"
-#include "modules/webrtc/webrtc_peer_connection_gdnative.h"
-#endif
-
-extern "C" {
-
-void GDAPI godot_net_bind_webrtc_peer_connection(godot_object *p_obj, const godot_net_webrtc_peer_connection *p_impl) {
-#ifdef WEBRTC_GDNATIVE_ENABLED
- ((WebRTCPeerConnectionGDNative *)p_obj)->set_native_webrtc_peer_connection(p_impl);
-#endif
-}
-
-void GDAPI godot_net_bind_webrtc_data_channel(godot_object *p_obj, const godot_net_webrtc_data_channel *p_impl) {
-#ifdef WEBRTC_GDNATIVE_ENABLED
- ((WebRTCDataChannelGDNative *)p_obj)->set_native_webrtc_data_channel(p_impl);
-#endif
-}
-
-godot_error GDAPI godot_net_set_webrtc_library(const godot_net_webrtc_library *p_lib) {
-#ifdef WEBRTC_GDNATIVE_ENABLED
- return (godot_error)WebRTCPeerConnectionGDNative::set_default_library(p_lib);
-#else
- return (godot_error)ERR_UNAVAILABLE;
-#endif
-}
-}
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index e4c2b20224..a4ab5663ef 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -35,7 +35,6 @@
#include "gdnative.h"
#include "nativescript/register_types.h"
-#include "net/register_types.h"
#include "pluginscript/register_types.h"
#include "videodecoder/register_types.h"
@@ -265,7 +264,6 @@ void register_gdnative_types() {
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
- register_net_types();
register_nativescript_types();
register_pluginscript_types();
register_videodecoder_types();
@@ -329,7 +327,6 @@ void unregister_gdnative_types() {
unregister_videodecoder_types();
unregister_pluginscript_types();
unregister_nativescript_types();
- unregister_net_types();
memdelete(GDNativeCallRegistry::singleton);
diff --git a/modules/webrtc/SCsub b/modules/webrtc/SCsub
index 31b8a73bf2..e6b9959840 100644
--- a/modules/webrtc/SCsub
+++ b/modules/webrtc/SCsub
@@ -4,11 +4,6 @@ Import("env")
Import("env_modules")
env_webrtc = env_modules.Clone()
-use_gdnative = env_webrtc["module_gdnative_enabled"]
-
-if use_gdnative: # GDNative is retained in Javascript for export compatibility
- env_webrtc.Append(CPPDEFINES=["WEBRTC_GDNATIVE_ENABLED"])
- env_webrtc.Prepend(CPPPATH=["#modules/gdnative/include/"])
if env["platform"] == "javascript":
# Our JavaScript/C++ interface.
diff --git a/modules/webrtc/config.py b/modules/webrtc/config.py
index 3281415f38..4ad918833a 100644
--- a/modules/webrtc/config.py
+++ b/modules/webrtc/config.py
@@ -11,6 +11,8 @@ def get_doc_classes():
"WebRTCPeerConnection",
"WebRTCDataChannel",
"WebRTCMultiplayerPeer",
+ "WebRTCPeerConnectionExtension",
+ "WebRTCDataChannelExtension",
]
diff --git a/modules/webrtc/doc_classes/WebRTCDataChannelExtension.xml b/modules/webrtc/doc_classes/WebRTCDataChannelExtension.xml
new file mode 100644
index 0000000000..26a4391b83
--- /dev/null
+++ b/modules/webrtc/doc_classes/WebRTCDataChannelExtension.xml
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="WebRTCDataChannelExtension" inherits="WebRTCDataChannel" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_close" qualifiers="virtual">
+ <return type="void" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_available_packet_count" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_buffered_amount" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_id" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_label" qualifiers="virtual const">
+ <return type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_packet_life_time" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_packet_size" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_max_retransmits" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="r_buffer" type="const void*" />
+ <argument index="1" name="r_buffer_size" type="int32_t*" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_protocol" qualifiers="virtual const">
+ <return type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_ready_state" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_write_mode" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_is_negotiated" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_is_ordered" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ <method name="_poll" qualifiers="virtual">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_put_packet" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_buffer" type="const void*" />
+ <argument index="1" name="p_buffer_size" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_write_mode" qualifiers="virtual">
+ <return type="void" />
+ <argument index="0" name="p_write_mode" type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_was_string_packet" qualifiers="virtual const">
+ <return type="bool" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml b/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
index 09556fa7cb..a8360a4d45 100644
--- a/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
+++ b/modules/webrtc/doc_classes/WebRTCMultiplayerPeer.xml
@@ -68,8 +68,4 @@
</description>
</method>
</methods>
- <members>
- <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="TransferMode" default="2" />
- </members>
</class>
diff --git a/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml b/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml
new file mode 100644
index 0000000000..d296fcd6e7
--- /dev/null
+++ b/modules/webrtc/doc_classes/WebRTCPeerConnectionExtension.xml
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="WebRTCPeerConnectionExtension" inherits="WebRTCPeerConnection" version="4.0">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="_add_ice_candidate" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_sdp_mid_name" type="String" />
+ <argument index="1" name="p_sdp_mline_index" type="int" />
+ <argument index="2" name="p_sdp_name" type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="_close" qualifiers="virtual">
+ <return type="void" />
+ <description>
+ </description>
+ </method>
+ <method name="_create_data_channel" qualifiers="virtual">
+ <return type="Object" />
+ <argument index="0" name="p_label" type="String" />
+ <argument index="1" name="p_config" type="Dictionary" />
+ <description>
+ </description>
+ </method>
+ <method name="_create_offer" qualifiers="virtual">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_get_connection_state" qualifiers="virtual const">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_initialize" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_config" type="Dictionary" />
+ <description>
+ </description>
+ </method>
+ <method name="_poll" qualifiers="virtual">
+ <return type="int" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_local_description" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_type" type="String" />
+ <argument index="1" name="p_sdp" type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="_set_remote_description" qualifiers="virtual">
+ <return type="int" />
+ <argument index="0" name="p_type" type="String" />
+ <argument index="1" name="p_sdp" type="String" />
+ <description>
+ </description>
+ </method>
+ <method name="make_default">
+ <return type="void" />
+ <description>
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/modules/webrtc/register_types.cpp b/modules/webrtc/register_types.cpp
index 63ecc03a4c..8110e4a048 100644
--- a/modules/webrtc/register_types.cpp
+++ b/modules/webrtc/register_types.cpp
@@ -31,17 +31,11 @@
#include "register_types.h"
#include "core/config/project_settings.h"
#include "webrtc_data_channel.h"
+#include "webrtc_multiplayer_peer.h"
#include "webrtc_peer_connection.h"
-#ifdef JAVASCRIPT_ENABLED
-#include "emscripten.h"
-#include "webrtc_peer_connection_js.h"
-#endif
-#ifdef WEBRTC_GDNATIVE_ENABLED
-#include "webrtc_data_channel_gdnative.h"
-#include "webrtc_peer_connection_gdnative.h"
-#endif
-#include "webrtc_multiplayer_peer.h"
+#include "webrtc_data_channel_extension.h"
+#include "webrtc_peer_connection_extension.h"
void register_webrtc_types() {
#define _SET_HINT(NAME, _VAL_, _MAX_) \
@@ -50,18 +44,12 @@ void register_webrtc_types() {
_SET_HINT(WRTC_IN_BUF, 64, 4096);
-#ifdef JAVASCRIPT_ENABLED
- WebRTCPeerConnectionJS::make_default();
-#elif defined(WEBRTC_GDNATIVE_ENABLED)
- WebRTCPeerConnectionGDNative::make_default();
-#endif
-
ClassDB::register_custom_instance_class<WebRTCPeerConnection>();
-#ifdef WEBRTC_GDNATIVE_ENABLED
- GDREGISTER_CLASS(WebRTCPeerConnectionGDNative);
- GDREGISTER_CLASS(WebRTCDataChannelGDNative);
-#endif
+ GDREGISTER_CLASS(WebRTCPeerConnectionExtension);
+
GDREGISTER_VIRTUAL_CLASS(WebRTCDataChannel);
+ GDREGISTER_CLASS(WebRTCDataChannelExtension);
+
GDREGISTER_CLASS(WebRTCMultiplayerPeer);
}
diff --git a/modules/webrtc/webrtc_data_channel_extension.cpp b/modules/webrtc/webrtc_data_channel_extension.cpp
new file mode 100644
index 0000000000..ae346f6d8e
--- /dev/null
+++ b/modules/webrtc/webrtc_data_channel_extension.cpp
@@ -0,0 +1,215 @@
+/*************************************************************************/
+/* webrtc_data_channel_extension.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "webrtc_data_channel_extension.h"
+
+void WebRTCDataChannelExtension::_bind_methods() {
+ ADD_PROPERTY_DEFAULT("write_mode", WRITE_MODE_BINARY);
+
+ GDVIRTUAL_BIND(_get_packet, "r_buffer", "r_buffer_size");
+ GDVIRTUAL_BIND(_put_packet, "p_buffer", "p_buffer_size");
+ GDVIRTUAL_BIND(_get_available_packet_count);
+ GDVIRTUAL_BIND(_get_max_packet_size);
+
+ GDVIRTUAL_BIND(_poll);
+ GDVIRTUAL_BIND(_close);
+
+ GDVIRTUAL_BIND(_set_write_mode, "p_write_mode");
+ GDVIRTUAL_BIND(_get_write_mode);
+
+ GDVIRTUAL_BIND(_was_string_packet);
+ GDVIRTUAL_BIND(_get_ready_state);
+ GDVIRTUAL_BIND(_get_label);
+ GDVIRTUAL_BIND(_is_ordered);
+ GDVIRTUAL_BIND(_get_id);
+ GDVIRTUAL_BIND(_get_max_packet_life_time);
+ GDVIRTUAL_BIND(_get_max_retransmits);
+ GDVIRTUAL_BIND(_get_protocol);
+ GDVIRTUAL_BIND(_is_negotiated);
+ GDVIRTUAL_BIND(_get_buffered_amount);
+}
+
+int WebRTCDataChannelExtension::get_available_packet_count() const {
+ int count;
+ if (GDVIRTUAL_CALL(_get_available_packet_count, count)) {
+ return count;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_available_packet_count is unimplemented!");
+ return -1;
+}
+
+Error WebRTCDataChannelExtension::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_get_packet, r_buffer, &r_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_packet_native is unimplemented!");
+ return FAILED;
+}
+
+Error WebRTCDataChannelExtension::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
+ int err;
+ if (GDVIRTUAL_CALL(_put_packet, p_buffer, p_buffer_size, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_put_packet_native is unimplemented!");
+ return FAILED;
+}
+
+int WebRTCDataChannelExtension::get_max_packet_size() const {
+ int size;
+ if (GDVIRTUAL_CALL(_get_max_packet_size, size)) {
+ return size;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_max_packet_size is unimplemented!");
+ return 0;
+}
+
+Error WebRTCDataChannelExtension::poll() {
+ int err;
+ if (GDVIRTUAL_CALL(_poll, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_poll is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+void WebRTCDataChannelExtension::close() {
+ if (GDVIRTUAL_CALL(_close)) {
+ return;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_close is unimplemented!");
+}
+
+void WebRTCDataChannelExtension::set_write_mode(WriteMode p_mode) {
+ if (GDVIRTUAL_CALL(_set_write_mode, p_mode)) {
+ return;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_set_write_mode is unimplemented!");
+}
+
+WebRTCDataChannel::WriteMode WebRTCDataChannelExtension::get_write_mode() const {
+ int mode;
+ if (GDVIRTUAL_CALL(_get_write_mode, mode)) {
+ return (WriteMode)mode;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_write_mode is unimplemented!");
+ return WRITE_MODE_BINARY;
+}
+
+bool WebRTCDataChannelExtension::was_string_packet() const {
+ bool was_string;
+ if (GDVIRTUAL_CALL(_was_string_packet, was_string)) {
+ return was_string;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_was_string_packet is unimplemented!");
+ return false;
+}
+
+WebRTCDataChannel::ChannelState WebRTCDataChannelExtension::get_ready_state() const {
+ int state;
+ if (GDVIRTUAL_CALL(_get_ready_state, state)) {
+ return (ChannelState)state;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_ready_state is unimplemented!");
+ return STATE_CLOSED;
+}
+
+String WebRTCDataChannelExtension::get_label() const {
+ String label;
+ if (GDVIRTUAL_CALL(_get_label, label)) {
+ return label;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_label is unimplemented!");
+ return label;
+}
+
+bool WebRTCDataChannelExtension::is_ordered() const {
+ bool ordered;
+ if (GDVIRTUAL_CALL(_is_ordered, ordered)) {
+ return ordered;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_is_ordered is unimplemented!");
+ return false;
+}
+
+int WebRTCDataChannelExtension::get_id() const {
+ int id;
+ if (GDVIRTUAL_CALL(_get_id, id)) {
+ return id;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_id is unimplemented!");
+ return -1;
+}
+
+int WebRTCDataChannelExtension::get_max_packet_life_time() const {
+ int lifetime;
+ if (GDVIRTUAL_CALL(_get_max_packet_life_time, lifetime)) {
+ return lifetime;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_max_packet_life_time is unimplemented!");
+ return -1;
+}
+
+int WebRTCDataChannelExtension::get_max_retransmits() const {
+ int retransmits;
+ if (GDVIRTUAL_CALL(_get_max_retransmits, retransmits)) {
+ return retransmits;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_max_retransmits is unimplemented!");
+ return -1;
+}
+
+String WebRTCDataChannelExtension::get_protocol() const {
+ String protocol;
+ if (GDVIRTUAL_CALL(_get_protocol, protocol)) {
+ return protocol;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_protocol is unimplemented!");
+ return protocol;
+}
+
+bool WebRTCDataChannelExtension::is_negotiated() const {
+ bool negotiated;
+ if (GDVIRTUAL_CALL(_is_negotiated, negotiated)) {
+ return negotiated;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_is_negotiated is unimplemented!");
+ return false;
+}
+
+int WebRTCDataChannelExtension::get_buffered_amount() const {
+ int amount;
+ if (GDVIRTUAL_CALL(_get_buffered_amount, amount)) {
+ return amount;
+ }
+ WARN_PRINT_ONCE("WebRTCDataChannelExtension::_get_buffered_amount is unimplemented!");
+ return -1;
+}
diff --git a/modules/webrtc/webrtc_data_channel_gdnative.h b/modules/webrtc/webrtc_data_channel_extension.h
index 5c80edd48c..eec96b4c62 100644
--- a/modules/webrtc/webrtc_data_channel_gdnative.h
+++ b/modules/webrtc/webrtc_data_channel_extension.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* webrtc_data_channel_gdnative.h */
+/* webrtc_data_channel_extension.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,26 +28,22 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef WEBRTC_DATA_CHANNEL_GDNATIVE_H
-#define WEBRTC_DATA_CHANNEL_GDNATIVE_H
+#ifndef WEBRTC_DATA_CHANNEL_EXTENSION_H
+#define WEBRTC_DATA_CHANNEL_EXTENSION_H
-#ifdef WEBRTC_GDNATIVE_ENABLED
-
-#include "modules/gdnative/include/net/godot_net.h"
#include "webrtc_data_channel.h"
-class WebRTCDataChannelGDNative : public WebRTCDataChannel {
- GDCLASS(WebRTCDataChannelGDNative, WebRTCDataChannel);
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
+class WebRTCDataChannelExtension : public WebRTCDataChannel {
+ GDCLASS(WebRTCDataChannelExtension, WebRTCDataChannel);
protected:
static void _bind_methods();
-private:
- const godot_net_webrtc_data_channel *interface;
-
public:
- void set_native_webrtc_data_channel(const godot_net_webrtc_data_channel *p_impl);
-
virtual void set_write_mode(WriteMode mode) override;
virtual WriteMode get_write_mode() const override;
virtual bool was_string_packet() const override;
@@ -72,10 +68,31 @@ public:
virtual int get_max_packet_size() const override;
- WebRTCDataChannelGDNative();
- ~WebRTCDataChannelGDNative();
-};
+ /** GDExtension **/
+ GDVIRTUAL0RC(int, _get_available_packet_count);
+ GDVIRTUAL2R(int, _get_packet, GDNativeConstPtr<const uint8_t *>, GDNativePtr<int>);
+ GDVIRTUAL2R(int, _put_packet, GDNativeConstPtr<const uint8_t>, int);
+ GDVIRTUAL0RC(int, _get_max_packet_size);
-#endif // WEBRTC_GDNATIVE_ENABLED
+ GDVIRTUAL0R(int, _poll);
+ GDVIRTUAL0(_close);
+
+ GDVIRTUAL1(_set_write_mode, int);
+ GDVIRTUAL0RC(int, _get_write_mode);
+
+ GDVIRTUAL0RC(bool, _was_string_packet);
+
+ GDVIRTUAL0RC(int, _get_ready_state);
+ GDVIRTUAL0RC(String, _get_label);
+ GDVIRTUAL0RC(bool, _is_ordered);
+ GDVIRTUAL0RC(int, _get_id);
+ GDVIRTUAL0RC(int, _get_max_packet_life_time);
+ GDVIRTUAL0RC(int, _get_max_retransmits);
+ GDVIRTUAL0RC(String, _get_protocol);
+ GDVIRTUAL0RC(bool, _is_negotiated);
+ GDVIRTUAL0RC(int, _get_buffered_amount);
+
+ WebRTCDataChannelExtension() {}
+};
-#endif // WEBRTC_DATA_CHANNEL_GDNATIVE_H
+#endif // WEBRTC_DATA_CHANNEL_EXTENSION_H
diff --git a/modules/webrtc/webrtc_data_channel_gdnative.cpp b/modules/webrtc/webrtc_data_channel_gdnative.cpp
deleted file mode 100644
index 10a3367557..0000000000
--- a/modules/webrtc/webrtc_data_channel_gdnative.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-/*************************************************************************/
-/* webrtc_data_channel_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifdef WEBRTC_GDNATIVE_ENABLED
-
-#include "webrtc_data_channel_gdnative.h"
-
-#include "core/io/resource_loader.h"
-#include "modules/gdnative/nativescript/nativescript.h"
-
-void WebRTCDataChannelGDNative::_bind_methods() {
- ADD_PROPERTY_DEFAULT("write_mode", WRITE_MODE_BINARY);
-}
-
-WebRTCDataChannelGDNative::WebRTCDataChannelGDNative() {
- interface = nullptr;
-}
-
-WebRTCDataChannelGDNative::~WebRTCDataChannelGDNative() {
-}
-
-Error WebRTCDataChannelGDNative::poll() {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->poll(interface->data);
-}
-
-void WebRTCDataChannelGDNative::close() {
- ERR_FAIL_COND(interface == nullptr);
- interface->close(interface->data);
-}
-
-void WebRTCDataChannelGDNative::set_write_mode(WriteMode p_mode) {
- ERR_FAIL_COND(interface == nullptr);
- interface->set_write_mode(interface->data, p_mode);
-}
-
-WebRTCDataChannel::WriteMode WebRTCDataChannelGDNative::get_write_mode() const {
- ERR_FAIL_COND_V(interface == nullptr, WRITE_MODE_BINARY);
- return (WriteMode)interface->get_write_mode(interface->data);
-}
-
-bool WebRTCDataChannelGDNative::was_string_packet() const {
- ERR_FAIL_COND_V(interface == nullptr, false);
- return interface->was_string_packet(interface->data);
-}
-
-WebRTCDataChannel::ChannelState WebRTCDataChannelGDNative::get_ready_state() const {
- ERR_FAIL_COND_V(interface == nullptr, STATE_CLOSED);
- return (ChannelState)interface->get_ready_state(interface->data);
-}
-
-String WebRTCDataChannelGDNative::get_label() const {
- ERR_FAIL_COND_V(interface == nullptr, "");
- return String(interface->get_label(interface->data));
-}
-
-bool WebRTCDataChannelGDNative::is_ordered() const {
- ERR_FAIL_COND_V(interface == nullptr, false);
- return interface->is_ordered(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_id() const {
- ERR_FAIL_COND_V(interface == nullptr, -1);
- return interface->get_id(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_max_packet_life_time() const {
- ERR_FAIL_COND_V(interface == nullptr, -1);
- return interface->get_max_packet_life_time(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_max_retransmits() const {
- ERR_FAIL_COND_V(interface == nullptr, -1);
- return interface->get_max_retransmits(interface->data);
-}
-
-String WebRTCDataChannelGDNative::get_protocol() const {
- ERR_FAIL_COND_V(interface == nullptr, "");
- return String(interface->get_protocol(interface->data));
-}
-
-bool WebRTCDataChannelGDNative::is_negotiated() const {
- ERR_FAIL_COND_V(interface == nullptr, false);
- return interface->is_negotiated(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_buffered_amount() const {
- ERR_FAIL_COND_V(interface == NULL, 0);
- return interface->get_buffered_amount(interface->data);
-}
-
-Error WebRTCDataChannelGDNative::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->get_packet(interface->data, r_buffer, &r_buffer_size);
-}
-
-Error WebRTCDataChannelGDNative::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->put_packet(interface->data, p_buffer, p_buffer_size);
-}
-
-int WebRTCDataChannelGDNative::get_max_packet_size() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_max_packet_size(interface->data);
-}
-
-int WebRTCDataChannelGDNative::get_available_packet_count() const {
- ERR_FAIL_COND_V(interface == nullptr, 0);
- return interface->get_available_packet_count(interface->data);
-}
-
-void WebRTCDataChannelGDNative::set_native_webrtc_data_channel(const godot_net_webrtc_data_channel *p_impl) {
- interface = p_impl;
-}
-
-#endif // WEBRTC_GDNATIVE_ENABLED
diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp
index d60d694df1..48117f05f2 100644
--- a/modules/webrtc/webrtc_multiplayer_peer.cpp
+++ b/modules/webrtc/webrtc_multiplayer_peer.cpp
@@ -43,22 +43,6 @@ void WebRTCMultiplayerPeer::_bind_methods() {
ClassDB::bind_method(D_METHOD("close"), &WebRTCMultiplayerPeer::close);
}
-void WebRTCMultiplayerPeer::set_transfer_channel(int p_channel) {
- transfer_channel = p_channel;
-}
-
-int WebRTCMultiplayerPeer::get_transfer_channel() const {
- return transfer_channel;
-}
-
-void WebRTCMultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
- transfer_mode = p_mode;
-}
-
-Multiplayer::TransferMode WebRTCMultiplayerPeer::get_transfer_mode() const {
- return transfer_mode;
-}
-
void WebRTCMultiplayerPeer::set_target_peer(int p_peer_id) {
target_peer = p_peer_id;
}
@@ -188,14 +172,6 @@ void WebRTCMultiplayerPeer::_find_next_peer() {
next_packet_peer = 0;
}
-void WebRTCMultiplayerPeer::set_refuse_new_connections(bool p_enable) {
- refuse_connections = p_enable;
-}
-
-bool WebRTCMultiplayerPeer::is_refusing_new_connections() const {
- return refuse_connections;
-}
-
MultiplayerPeer::ConnectionStatus WebRTCMultiplayerPeer::get_connection_status() const {
return connection_status;
}
@@ -279,7 +255,7 @@ Dictionary WebRTCMultiplayerPeer::get_peers() {
Error WebRTCMultiplayerPeer::add_peer(Ref<WebRTCPeerConnection> p_peer, int p_peer_id, int p_unreliable_lifetime) {
ERR_FAIL_COND_V(p_peer_id < 0 || p_peer_id > ~(1 << 31), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_unreliable_lifetime < 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(refuse_connections, ERR_UNAUTHORIZED);
+ ERR_FAIL_COND_V(is_refusing_new_connections(), ERR_UNAUTHORIZED);
// Peer must be valid, and in new state (to create data channels)
ERR_FAIL_COND_V(!p_peer.is_valid(), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V(p_peer->get_connection_state() != WebRTCPeerConnection::STATE_NEW, ERR_INVALID_PARAMETER);
@@ -352,9 +328,9 @@ Error WebRTCMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_
Error WebRTCMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
ERR_FAIL_COND_V(connection_status == CONNECTION_DISCONNECTED, ERR_UNCONFIGURED);
- int ch = transfer_channel;
+ int ch = get_transfer_channel();
if (ch == 0) {
- switch (transfer_mode) {
+ switch (get_transfer_mode()) {
case Multiplayer::TRANSFER_MODE_RELIABLE:
ch = CH_RELIABLE;
break;
diff --git a/modules/webrtc/webrtc_multiplayer_peer.h b/modules/webrtc/webrtc_multiplayer_peer.h
index 80a6491492..4a7e9ad7c8 100644
--- a/modules/webrtc/webrtc_multiplayer_peer.h
+++ b/modules/webrtc/webrtc_multiplayer_peer.h
@@ -65,10 +65,7 @@ private:
uint32_t unique_id = 0;
int target_peer = 0;
int client_count = 0;
- bool refuse_connections = false;
ConnectionStatus connection_status = CONNECTION_DISCONNECTED;
- int transfer_channel = 0;
- Multiplayer::TransferMode transfer_mode = Multiplayer::TRANSFER_MODE_RELIABLE;
int next_packet_peer = 0;
bool server_compat = false;
@@ -97,10 +94,6 @@ public:
int get_max_packet_size() const override;
// MultiplayerPeer
- void set_transfer_channel(int p_channel) override;
- int get_transfer_channel() const override;
- void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
- Multiplayer::TransferMode get_transfer_mode() const override;
void set_target_peer(int p_peer_id) override;
int get_unique_id() const override;
@@ -110,9 +103,6 @@ public:
void poll() override;
- void set_refuse_new_connections(bool p_enable) override;
- bool is_refusing_new_connections() const override;
-
ConnectionStatus get_connection_status() const override;
};
diff --git a/modules/webrtc/webrtc_peer_connection.cpp b/modules/webrtc/webrtc_peer_connection.cpp
index 3e2938bf7d..ad28aa76c7 100644
--- a/modules/webrtc/webrtc_peer_connection.cpp
+++ b/modules/webrtc/webrtc_peer_connection.cpp
@@ -30,17 +30,29 @@
#include "webrtc_peer_connection.h"
-WebRTCPeerConnection *(*WebRTCPeerConnection::_create)() = nullptr;
+#ifdef JAVASCRIPT_ENABLED
+#include "webrtc_peer_connection_js.h"
+#else
+#include "webrtc_peer_connection_extension.h"
+#endif
-Ref<WebRTCPeerConnection> WebRTCPeerConnection::create_ref() {
- return create();
+StringName WebRTCPeerConnection::default_extension;
+
+void WebRTCPeerConnection::set_default_extension(const StringName &p_extension) {
+ default_extension = p_extension;
}
WebRTCPeerConnection *WebRTCPeerConnection::create() {
- if (!_create) {
- return nullptr;
+#ifdef JAVASCRIPT_ENABLED
+ return memnew(WebRTCPeerConnectionJS);
+#else
+ if (default_extension == String()) {
+ WARN_PRINT_ONCE("No default WebRTC extension configured.");
+ return memnew(WebRTCPeerConnectionExtension);
}
- return _create();
+ Object *obj = ClassDB::instantiate(default_extension);
+ return Object::cast_to<WebRTCPeerConnectionExtension>(obj);
+#endif
}
void WebRTCPeerConnection::_bind_methods() {
diff --git a/modules/webrtc/webrtc_peer_connection.h b/modules/webrtc/webrtc_peer_connection.h
index fcfb9ae9ae..e2ef3e55ad 100644
--- a/modules/webrtc/webrtc_peer_connection.h
+++ b/modules/webrtc/webrtc_peer_connection.h
@@ -47,11 +47,15 @@ public:
STATE_CLOSED
};
+private:
+ static StringName default_extension;
+
protected:
static void _bind_methods();
- static WebRTCPeerConnection *(*_create)();
public:
+ static void set_default_extension(const StringName &p_name);
+
virtual ConnectionState get_connection_state() const = 0;
virtual Error initialize(Dictionary p_config = Dictionary()) = 0;
@@ -63,7 +67,6 @@ public:
virtual Error poll() = 0;
virtual void close() = 0;
- static Ref<WebRTCPeerConnection> create_ref();
static WebRTCPeerConnection *create();
WebRTCPeerConnection();
diff --git a/modules/webrtc/webrtc_peer_connection_extension.cpp b/modules/webrtc/webrtc_peer_connection_extension.cpp
new file mode 100644
index 0000000000..33288e66d6
--- /dev/null
+++ b/modules/webrtc/webrtc_peer_connection_extension.cpp
@@ -0,0 +1,131 @@
+/*************************************************************************/
+/* webrtc_peer_connection_extension.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "webrtc_peer_connection_extension.h"
+
+void WebRTCPeerConnectionExtension::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("make_default"), &WebRTCPeerConnectionExtension::make_default);
+
+ GDVIRTUAL_BIND(_get_connection_state);
+ GDVIRTUAL_BIND(_initialize, "p_config");
+ GDVIRTUAL_BIND(_create_data_channel, "p_label", "p_config");
+ GDVIRTUAL_BIND(_create_offer);
+ GDVIRTUAL_BIND(_set_remote_description, "p_type", "p_sdp");
+ GDVIRTUAL_BIND(_set_local_description, "p_type", "p_sdp");
+ GDVIRTUAL_BIND(_add_ice_candidate, "p_sdp_mid_name", "p_sdp_mline_index", "p_sdp_name");
+ GDVIRTUAL_BIND(_poll);
+ GDVIRTUAL_BIND(_close);
+}
+
+void WebRTCPeerConnectionExtension::make_default() {
+ ERR_FAIL_COND_MSG(!_get_extension(), vformat("Can't make %s the default without extending it.", get_class()));
+ WebRTCPeerConnection::set_default_extension(get_class());
+}
+
+WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionExtension::get_connection_state() const {
+ int state;
+ if (GDVIRTUAL_CALL(_get_connection_state, state)) {
+ return (ConnectionState)state;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_get_connection_state is unimplemented!");
+ return STATE_DISCONNECTED;
+}
+
+Error WebRTCPeerConnectionExtension::initialize(Dictionary p_config) {
+ int err;
+ if (GDVIRTUAL_CALL(_initialize, p_config, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_initialize is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Ref<WebRTCDataChannel> WebRTCPeerConnectionExtension::create_data_channel(String p_label, Dictionary p_options) {
+ Object *ret = nullptr;
+ if (GDVIRTUAL_CALL(_create_data_channel, p_label, p_options, ret)) {
+ WebRTCDataChannel *ch = Object::cast_to<WebRTCDataChannel>(ret);
+ ERR_FAIL_COND_V_MSG(ret && !ch, nullptr, "Returned object must be an instance of WebRTCDataChannel.");
+ return ch;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_create_data_channel is unimplemented!");
+ return nullptr;
+}
+
+Error WebRTCPeerConnectionExtension::create_offer() {
+ int err;
+ if (GDVIRTUAL_CALL(_create_offer, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_create_offer is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Error WebRTCPeerConnectionExtension::set_local_description(String p_type, String p_sdp) {
+ int err;
+ if (GDVIRTUAL_CALL(_set_local_description, p_type, p_sdp, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_set_local_description is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Error WebRTCPeerConnectionExtension::set_remote_description(String p_type, String p_sdp) {
+ int err;
+ if (GDVIRTUAL_CALL(_set_remote_description, p_type, p_sdp, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_set_remote_description is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Error WebRTCPeerConnectionExtension::add_ice_candidate(String p_sdp_mid_name, int p_sdp_mline_index, String p_sdp_name) {
+ int err;
+ if (GDVIRTUAL_CALL(_add_ice_candidate, p_sdp_mid_name, p_sdp_mline_index, p_sdp_name, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_add_ice_candidate is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+Error WebRTCPeerConnectionExtension::poll() {
+ int err;
+ if (GDVIRTUAL_CALL(_poll, err)) {
+ return (Error)err;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_poll is unimplemented!");
+ return ERR_UNCONFIGURED;
+}
+
+void WebRTCPeerConnectionExtension::close() {
+ if (GDVIRTUAL_CALL(_close)) {
+ return;
+ }
+ WARN_PRINT_ONCE("WebRTCPeerConnectionExtension::_close is unimplemented!");
+}
diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.h b/modules/webrtc/webrtc_peer_connection_extension.h
index 578af0202f..b3c2039fc1 100644
--- a/modules/webrtc/webrtc_peer_connection_gdnative.h
+++ b/modules/webrtc/webrtc_peer_connection_extension.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* webrtc_peer_connection_gdnative.h */
+/* webrtc_peer_connection_extension.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,30 +28,23 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef WEBRTC_PEER_CONNECTION_GDNATIVE_H
-#define WEBRTC_PEER_CONNECTION_GDNATIVE_H
+#ifndef WEBRTC_PEER_CONNECTION_EXTENSION_H
+#define WEBRTC_PEER_CONNECTION_EXTENSION_H
-#ifdef WEBRTC_GDNATIVE_ENABLED
-
-#include "modules/gdnative/include/net/godot_net.h"
#include "webrtc_peer_connection.h"
-class WebRTCPeerConnectionGDNative : public WebRTCPeerConnection {
- GDCLASS(WebRTCPeerConnectionGDNative, WebRTCPeerConnection);
+#include "core/object/gdvirtual.gen.inc"
+#include "core/object/script_language.h"
+#include "core/variant/native_ptr.h"
+
+class WebRTCPeerConnectionExtension : public WebRTCPeerConnection {
+ GDCLASS(WebRTCPeerConnectionExtension, WebRTCPeerConnection);
protected:
static void _bind_methods();
- static WebRTCPeerConnection *_create();
-
-private:
- static const godot_net_webrtc_library *default_library;
- const godot_net_webrtc_peer_connection *interface;
public:
- static Error set_default_library(const godot_net_webrtc_library *p_library);
- static void make_default() { WebRTCPeerConnection::_create = WebRTCPeerConnectionGDNative::_create; }
-
- void set_native_webrtc_peer_connection(const godot_net_webrtc_peer_connection *p_impl);
+ void make_default();
virtual ConnectionState get_connection_state() const override;
@@ -60,14 +53,22 @@ public:
virtual Error create_offer() override;
virtual Error set_remote_description(String type, String sdp) override;
virtual Error set_local_description(String type, String sdp) override;
- virtual Error add_ice_candidate(String sdpMidName, int sdpMlineIndexName, String sdpName) override;
+ virtual Error add_ice_candidate(String p_sdp_mid_name, int p_sdp_mline_index, String p_sdp_name) override;
virtual Error poll() override;
virtual void close() override;
- WebRTCPeerConnectionGDNative();
- ~WebRTCPeerConnectionGDNative();
-};
+ /** GDExtension **/
+ GDVIRTUAL0RC(int, _get_connection_state);
+ GDVIRTUAL1R(int, _initialize, Dictionary);
+ GDVIRTUAL2R(Object *, _create_data_channel, String, Dictionary);
+ GDVIRTUAL0R(int, _create_offer);
+ GDVIRTUAL2R(int, _set_remote_description, String, String);
+ GDVIRTUAL2R(int, _set_local_description, String, String);
+ GDVIRTUAL3R(int, _add_ice_candidate, String, int, String);
+ GDVIRTUAL0R(int, _poll);
+ GDVIRTUAL0(_close);
-#endif // WEBRTC_GDNATIVE_ENABLED
+ WebRTCPeerConnectionExtension() {}
+};
-#endif // WEBRTC_PEER_CONNECTION_GDNATIVE_H
+#endif // WEBRTC_PEER_CONNECTION_EXTENSION_H
diff --git a/modules/webrtc/webrtc_peer_connection_gdnative.cpp b/modules/webrtc/webrtc_peer_connection_gdnative.cpp
deleted file mode 100644
index dcf78dfb73..0000000000
--- a/modules/webrtc/webrtc_peer_connection_gdnative.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*************************************************************************/
-/* webrtc_peer_connection_gdnative.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-
-#ifdef WEBRTC_GDNATIVE_ENABLED
-
-#include "webrtc_peer_connection_gdnative.h"
-
-#include "core/io/resource_loader.h"
-#include "modules/gdnative/nativescript/nativescript.h"
-#include "webrtc_data_channel_gdnative.h"
-
-const godot_net_webrtc_library *WebRTCPeerConnectionGDNative::default_library = nullptr;
-
-Error WebRTCPeerConnectionGDNative::set_default_library(const godot_net_webrtc_library *p_lib) {
- if (default_library) {
- const godot_net_webrtc_library *old = default_library;
- default_library = nullptr;
- old->unregistered();
- }
- default_library = p_lib;
- return OK; // Maybe add version check and fail accordingly
-}
-
-WebRTCPeerConnection *WebRTCPeerConnectionGDNative::_create() {
- WebRTCPeerConnectionGDNative *obj = memnew(WebRTCPeerConnectionGDNative);
- ERR_FAIL_COND_V_MSG(!default_library, obj, "Default GDNative WebRTC implementation not defined.");
-
- // Call GDNative constructor
- Error err = (Error)default_library->create_peer_connection(obj);
- ERR_FAIL_COND_V_MSG(err != OK, obj, "GDNative default library constructor returned an error.");
-
- return obj;
-}
-
-void WebRTCPeerConnectionGDNative::_bind_methods() {
-}
-
-WebRTCPeerConnectionGDNative::WebRTCPeerConnectionGDNative() {
- interface = nullptr;
-}
-
-WebRTCPeerConnectionGDNative::~WebRTCPeerConnectionGDNative() {
-}
-
-Error WebRTCPeerConnectionGDNative::initialize(Dictionary p_config) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->initialize(interface->data, (const godot_dictionary *)&p_config);
-}
-
-Ref<WebRTCDataChannel> WebRTCPeerConnectionGDNative::create_data_channel(String p_label, Dictionary p_options) {
- ERR_FAIL_COND_V(interface == nullptr, nullptr);
- return (WebRTCDataChannel *)interface->create_data_channel(interface->data, p_label.utf8().get_data(), (const godot_dictionary *)&p_options);
-}
-
-Error WebRTCPeerConnectionGDNative::create_offer() {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->create_offer(interface->data);
-}
-
-Error WebRTCPeerConnectionGDNative::set_local_description(String p_type, String p_sdp) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->set_local_description(interface->data, p_type.utf8().get_data(), p_sdp.utf8().get_data());
-}
-
-Error WebRTCPeerConnectionGDNative::set_remote_description(String p_type, String p_sdp) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->set_remote_description(interface->data, p_type.utf8().get_data(), p_sdp.utf8().get_data());
-}
-
-Error WebRTCPeerConnectionGDNative::add_ice_candidate(String sdpMidName, int sdpMlineIndexName, String sdpName) {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->add_ice_candidate(interface->data, sdpMidName.utf8().get_data(), sdpMlineIndexName, sdpName.utf8().get_data());
-}
-
-Error WebRTCPeerConnectionGDNative::poll() {
- ERR_FAIL_COND_V(interface == nullptr, ERR_UNCONFIGURED);
- return (Error)interface->poll(interface->data);
-}
-
-void WebRTCPeerConnectionGDNative::close() {
- ERR_FAIL_COND(interface == nullptr);
- interface->close(interface->data);
-}
-
-WebRTCPeerConnection::ConnectionState WebRTCPeerConnectionGDNative::get_connection_state() const {
- ERR_FAIL_COND_V(interface == nullptr, STATE_DISCONNECTED);
- return (ConnectionState)interface->get_connection_state(interface->data);
-}
-
-void WebRTCPeerConnectionGDNative::set_native_webrtc_peer_connection(const godot_net_webrtc_peer_connection *p_impl) {
- interface = p_impl;
-}
-
-#endif // WEBRTC_GDNATIVE_ENABLED
diff --git a/modules/webrtc/webrtc_peer_connection_js.h b/modules/webrtc/webrtc_peer_connection_js.h
index 0272e67f6f..d2beccaf03 100644
--- a/modules/webrtc/webrtc_peer_connection_js.h
+++ b/modules/webrtc/webrtc_peer_connection_js.h
@@ -63,9 +63,6 @@ private:
static void _on_error(void *p_obj);
public:
- static WebRTCPeerConnection *_create() { return memnew(WebRTCPeerConnectionJS); }
- static void make_default() { WebRTCPeerConnection::_create = WebRTCPeerConnectionJS::_create; }
-
virtual ConnectionState get_connection_state() const;
virtual Error initialize(Dictionary configuration = Dictionary());
diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
index f75a42357a..8d8ab220e2 100644
--- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
+++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
@@ -31,10 +31,6 @@
</description>
</method>
</methods>
- <members>
- <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
- <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="TransferMode" default="2" />
- </members>
<signals>
<signal name="peer_packet">
<argument index="0" name="peer_source" type="int" />
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 7464cf2bf5..3a27855a5e 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/modules/websocket/websocket_multiplayer_peer.cpp
@@ -105,23 +105,6 @@ Error WebSocketMultiplayerPeer::put_packet(const uint8_t *p_buffer, int p_buffer
//
// MultiplayerPeer
//
-void WebSocketMultiplayerPeer::set_transfer_channel(int p_channel) {
- // Websocket does not have channels.
-}
-
-int WebSocketMultiplayerPeer::get_transfer_channel() const {
- return 0;
-}
-
-void WebSocketMultiplayerPeer::set_transfer_mode(Multiplayer::TransferMode p_mode) {
- // Websocket uses TCP, reliable
-}
-
-Multiplayer::TransferMode WebSocketMultiplayerPeer::get_transfer_mode() const {
- // Websocket uses TCP, reliable
- return Multiplayer::TRANSFER_MODE_RELIABLE;
-}
-
void WebSocketMultiplayerPeer::set_target_peer(int p_target_peer) {
_target_peer = p_target_peer;
}
@@ -137,14 +120,6 @@ int WebSocketMultiplayerPeer::get_unique_id() const {
return _peer_id;
}
-void WebSocketMultiplayerPeer::set_refuse_new_connections(bool p_enable) {
- _refusing = p_enable;
-}
-
-bool WebSocketMultiplayerPeer::is_refusing_new_connections() const {
- return _refusing;
-}
-
void WebSocketMultiplayerPeer::_send_sys(Ref<WebSocketPeer> p_peer, uint8_t p_type, int32_t p_peer_id) {
ERR_FAIL_COND(!p_peer.is_valid());
ERR_FAIL_COND(!p_peer->is_connected_to_host());
diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h
index d97a599fe9..380edf67ed 100644
--- a/modules/websocket/websocket_multiplayer_peer.h
+++ b/modules/websocket/websocket_multiplayer_peer.h
@@ -68,7 +68,6 @@ protected:
bool _is_multiplayer = false;
int _target_peer = 0;
int _peer_id = 0;
- int _refusing = false;
static void _bind_methods();
@@ -78,15 +77,9 @@ protected:
public:
/* MultiplayerPeer */
- void set_transfer_channel(int p_channel) override;
- int get_transfer_channel() const override;
- void set_transfer_mode(Multiplayer::TransferMode p_mode) override;
- Multiplayer::TransferMode get_transfer_mode() const override;
void set_target_peer(int p_target_peer) override;
int get_packet_peer() const override;
int get_unique_id() const override;
- void set_refuse_new_connections(bool p_enable) override;
- bool is_refusing_new_connections() const override;
/* PacketPeer */
virtual int get_available_packet_count() const override;