summaryrefslogtreecommitdiff
path: root/modules/webrtc/webrtc_data_channel_js.h
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webrtc/webrtc_data_channel_js.h')
-rw-r--r--modules/webrtc/webrtc_data_channel_js.h68
1 files changed, 34 insertions, 34 deletions
diff --git a/modules/webrtc/webrtc_data_channel_js.h b/modules/webrtc/webrtc_data_channel_js.h
index 00b5963ea1..db58ebccff 100644
--- a/modules/webrtc/webrtc_data_channel_js.h
+++ b/modules/webrtc/webrtc_data_channel_js.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* 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 */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef JAVASCRIPT_ENABLED
-
#ifndef WEBRTC_DATA_CHANNEL_JS_H
#define WEBRTC_DATA_CHANNEL_JS_H
+#ifdef JAVASCRIPT_ENABLED
+
#include "webrtc_data_channel.h"
class WebRTCDataChannelJS : public WebRTCDataChannel {
@@ -42,52 +42,52 @@ private:
String _label;
String _protocol;
- bool _was_string;
- WriteMode _write_mode;
+ bool _was_string = false;
+ WriteMode _write_mode = WRITE_MODE_BINARY;
enum {
PACKET_BUFFER_SIZE = 65536 - 5 // 4 bytes for the size, 1 for for type
};
- int _js_id;
+ int _js_id = 0;
RingBuffer<uint8_t> in_buffer;
- int queue_count;
+ int queue_count = 0;
uint8_t packet_buffer[PACKET_BUFFER_SIZE];
+ static void _on_open(void *p_obj);
+ static void _on_close(void *p_obj);
+ static void _on_error(void *p_obj);
+ static void _on_message(void *p_obj, const uint8_t *p_data, int p_size, int p_is_string);
+
public:
- void _on_open();
- void _on_close();
- void _on_error();
- void _on_message(uint8_t *p_data, uint32_t p_size, bool p_is_string);
-
- virtual void set_write_mode(WriteMode mode);
- virtual WriteMode get_write_mode() const;
- virtual bool was_string_packet() const;
-
- virtual ChannelState get_ready_state() const;
- virtual String get_label() const;
- virtual bool is_ordered() const;
- virtual int get_id() const;
- virtual int get_max_packet_life_time() const;
- virtual int get_max_retransmits() const;
- virtual String get_protocol() const;
- virtual bool is_negotiated() const;
-
- virtual Error poll();
- virtual void close();
+ virtual void set_write_mode(WriteMode mode) override;
+ virtual WriteMode get_write_mode() const override;
+ virtual bool was_string_packet() const override;
+
+ virtual ChannelState get_ready_state() const override;
+ virtual String get_label() const override;
+ virtual bool is_ordered() const override;
+ virtual int get_id() const override;
+ virtual int get_max_packet_life_time() const override;
+ virtual int get_max_retransmits() const override;
+ virtual String get_protocol() const override;
+ virtual bool is_negotiated() const override;
+
+ virtual Error poll() override;
+ virtual void close() override;
/** Inherited from PacketPeer: **/
- virtual int get_available_packet_count() const;
- virtual Error get_packet(const uint8_t **r_buffer, int &r_buffer_size); ///< buffer is GONE after next get_packet
- virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
+ 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;
+ virtual int get_max_packet_size() const override;
WebRTCDataChannelJS();
WebRTCDataChannelJS(int js_id);
~WebRTCDataChannelJS();
};
-#endif // WEBRTC_DATA_CHANNEL_JS_H
-
#endif // JAVASCRIPT_ENABLED
+
+#endif // WEBRTC_DATA_CHANNEL_JS_H