mirror of
https://github.com/godotengine/webrtc-native.git
synced 2026-01-03 14:09:58 +03:00
Fix interface binding
This commit is contained in:
@@ -61,12 +61,12 @@ void WebRTCPeer::_register_methods() { }
|
||||
|
||||
void WebRTCPeer::_init() {
|
||||
printf("Binding PacketPeer interface");
|
||||
godot_net_bind_webrtc_peer(_owner, &interface);
|
||||
register_interface(&interface);
|
||||
}
|
||||
|
||||
WebRTCPeer::~WebRTCPeer() {
|
||||
if (_owner) {
|
||||
printf("Unbinding PacketPeer interface");
|
||||
godot_net_bind_webrtc_peer(_owner, NULL);
|
||||
register_interface(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
#include <gdnative_api_struct.gen.h>
|
||||
#include "net/WebRTCPeerNative.hpp"
|
||||
#include "WebRTCPeer.hpp"
|
||||
|
||||
/* Godot export stuff */
|
||||
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
|
||||
const godot_gdnative_core_api_struct *api = o->api_struct;
|
||||
for (int i = 0; i < api->num_extensions; i++) {
|
||||
if (api->extensions[i]->type == GDNATIVE_EXT_NET) {
|
||||
WebRTCPeerNative::_net_api = (godot_gdnative_ext_net_api_struct *)api->extensions[i];
|
||||
}
|
||||
}
|
||||
|
||||
godot::Godot::gdnative_init(o);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user