From 5d15ebb7237d37fdc49e8e19dacb4574b03f157d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Aug 2021 20:21:56 +1200 Subject: [PATCH] WebRTC data channel with assignment clients --- libraries/networking/src/webrtc/WebRTCDataChannels.cpp | 8 +++++++- libraries/networking/src/webrtc/WebRTCDataChannels.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp index 974cef2997..c62bca72c4 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.cpp +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.cpp @@ -452,12 +452,18 @@ void WebRTCDataChannels::onSignalingMessage(const QJsonObject& message) { const int MAX_DEBUG_DETAIL_LENGTH = 64; auto data = message.value("data").isObject() ? message.value("data").toObject() : QJsonObject(); int from = message.value("from").isDouble() ? (quint16)(message.value("from").toInt()) : 0; - if (from <= 0 || from > MAXUINT16 || !data.contains("description") && !data.contains("candidate")) { + auto to = NodeType::fromChar(message.value("to").toString().at(0)); + + if (from <= 0 || from > MAXUINT16 || to == NodeType::Unassigned + || !data.contains("description") && !data.contains("candidate")) { qCWarning(networking_webrtc) << "Unexpected signaling message:" << QJsonDocument(message).toJson(QJsonDocument::Compact).left(MAX_DEBUG_DETAIL_LENGTH); return; } + // Remember this node's type for the reply. + _nodeType = to; + // Find or create a connection. WDCConnection* connection; if (_connectionsByWebSocket.contains(from)) { diff --git a/libraries/networking/src/webrtc/WebRTCDataChannels.h b/libraries/networking/src/webrtc/WebRTCDataChannels.h index ec6f67b3c7..f6287c3717 100644 --- a/libraries/networking/src/webrtc/WebRTCDataChannels.h +++ b/libraries/networking/src/webrtc/WebRTCDataChannels.h @@ -319,7 +319,7 @@ private: QObject* _parent; - NodeType_t _nodeType; + NodeType_t _nodeType { NodeType::Unassigned }; std::unique_ptr _rtcNetworkThread { nullptr }; std::unique_ptr _rtcWorkerThread { nullptr };