diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2018-08-12 16:31:44 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2018-08-12 16:59:59 +0200 |
commit | 662ceddd518faab8137d922e29030dc3fa1e34e2 (patch) | |
tree | a9c7a17b4a14f83f67bb02a82237558633ce7c77 /src/net | |
parent | 1885036052b24cbe804bb829a32ba2617eac3fe4 (diff) | |
download | fork-godot-webrtc-native-662ceddd518faab8137d922e29030dc3fa1e34e2.tar.gz fork-godot-webrtc-native-662ceddd518faab8137d922e29030dc3fa1e34e2.tar.bz2 fork-godot-webrtc-native-662ceddd518faab8137d922e29030dc3fa1e34e2.zip |
Fix interface binding
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/WebRTCPeerNative.cpp | 11 | ||||
-rw-r--r-- | src/net/WebRTCPeerNative.hpp | 2 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/net/WebRTCPeerNative.cpp b/src/net/WebRTCPeerNative.cpp index 0e32d61..be9040c 100644 --- a/src/net/WebRTCPeerNative.cpp +++ b/src/net/WebRTCPeerNative.cpp @@ -1,16 +1,23 @@ #include "WebRTCPeerNative.hpp" +const godot_gdnative_ext_net_api_struct *WebRTCPeerNative::_net_api = NULL; + +void WebRTCPeerNative::register_interface(const godot_net_webrtc_peer *p_interface) { + ERR_FAIL_COND(!_net_api); + _net_api->godot_net_bind_webrtc_peer(_owner, p_interface); +} + void WebRTCPeerNative::_register_methods() { } void WebRTCPeerNative::_init() { printf("Binding PacketPeer interface"); - godot_net_bind_webrtc_peer(_owner, &interface); + register_interface(&interface); } WebRTCPeerNative::~WebRTCPeerNative() { if (_owner) { printf("Unbinding PacketPeer interface"); - godot_net_bind_webrtc_peer(_owner, NULL); + register_interface(NULL); } } diff --git a/src/net/WebRTCPeerNative.hpp b/src/net/WebRTCPeerNative.hpp index 6387cb1..603ba34 100644 --- a/src/net/WebRTCPeerNative.hpp +++ b/src/net/WebRTCPeerNative.hpp @@ -52,8 +52,10 @@ protected: public: static void _register_methods(); + static const godot_gdnative_ext_net_api_struct *_net_api; void _init(); + void register_interface(const godot_net_webrtc_peer *interface); virtual void set_write_mode(godot_int mode) = 0; virtual godot_int get_write_mode() const = 0; |