summaryrefslogtreecommitdiff
path: root/src/GodotDataChannelObserver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/GodotDataChannelObserver.cpp')
-rw-r--r--src/GodotDataChannelObserver.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/GodotDataChannelObserver.cpp b/src/GodotDataChannelObserver.cpp
new file mode 100644
index 0000000..081c868
--- /dev/null
+++ b/src/GodotDataChannelObserver.cpp
@@ -0,0 +1,19 @@
+#include "WebRTCPeer.hpp"
+
+using namespace godot_webrtc;
+
+WebRTCPeer::GodotDCO::GodotDCO(WebRTCPeer *parent) {
+ this->parent = parent;
+}
+
+void WebRTCPeer::GodotDCO::OnMessage(const webrtc::DataBuffer &buffer) {
+ const uint8_t *data = buffer.data.data<uint8_t>();
+ uint8_t *memory_controlled_buffer = new uint8_t[buffer.data.size()];
+
+ std::copy(data, data + buffer.data.size(), memory_controlled_buffer);
+ parent->queue_packet(memory_controlled_buffer, buffer.data.size());
+};
+
+void WebRTCPeer::GodotDCO::OnStateChange(){};
+
+void WebRTCPeer::GodotDCO::OnBufferedAmountChange(uint64_t previous_amount){};