From 7ecd9b6b8e83456715e90407667c91f35991e39e Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 4 Jul 2021 16:38:47 +1200 Subject: [PATCH] Miscellaneous tidying --- .../networking/src/webrtc/WebRTCDataChannels.cpp | 12 +++++++----- libraries/networking/src/webrtc/WebRTCDataChannels.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp index 48ec1b7b9b..69c954ad4b 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp @@ -21,6 +21,7 @@ // - https://webrtc.googlesource.com/src/+/master/api/peer_connection_interface.h const std::string ICE_SERVER_URI = "stun://ice.vircadia.com:7337"; +const int MAX_WEBRTC_BUFFER_SIZE = 16777216; // 16MB // #define WEBRTC_DEBUG @@ -128,9 +129,9 @@ void WDCDataChannelObserver::OnMessage(const DataBuffer& buffer) { } -WDCConnection::WDCConnection(quint16 webSocketID, WebRTCDataChannels* parent) : - _webSocketID(webSocketID), - _parent(parent) +WDCConnection::WDCConnection(WebRTCDataChannels* parent, quint16 webSocketID) : + _parent(parent), + _webSocketID(webSocketID) { #ifdef WEBRTC_DEBUG qCDebug(networking_webrtc) << "WDCConnection::WDCConnection() :" << webSocketID; @@ -333,10 +334,11 @@ bool WDCConnection::sendDataMessage(const DataBuffer& buffer) { #ifdef WEBRTC_DEBUG qCDebug(networking_webrtc) << "WDCConnection::sendDataMessage()"; #endif - const int MAX_WEBRTC_BUFFER_SIZE = 16 * 1024 * 1024; // 16MB if (_dataChannel->buffered_amount() + buffer.size() > MAX_WEBRTC_BUFFER_SIZE) { // Don't send, otherwise the data channel will be closed. return false; + } else { + qCDebug(networking_webrtc) << "WebRTC send buffer overflow"; } return _dataChannel->Send(buffer); } @@ -440,7 +442,7 @@ void WebRTCDataChannels::onSignalingMessage(const QJsonObject& message) { if (_connectionsByWebSocket.contains(from)) { connection = _connectionsByWebSocket.value(from); } else { - connection = new WDCConnection(from, this); + connection = new WDCConnection(this, from); _connectionsByWebSocket.insert(from, connection); } diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.h b/libraries/networking/src/webrtc/WebRTCDataChannels.h index 3edf9f9b9a..75325781ed 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.h +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.h @@ -129,9 +129,9 @@ class WDCConnection { public: /// @brief Constructs a new WDCConnection and opens a WebRTC data connection. - /// @param webSocketID The signaling channel that initiated the opening of the WebRTC data channel. /// @param parent The parent WebRTCDataChannels object. - WDCConnection(quint16 webSocketID, WebRTCDataChannels* parent); + /// @param webSocketID The signaling channel that initiated the opening of the WebRTC data channel. + WDCConnection(WebRTCDataChannels* parent, quint16 webSocketID); /// @brief Gets the WebSocket ID. /// @return The ID of the WebSocket.