an initial take on a alternative remote connection
This commit is contained in:
parent
f9343534f4
commit
c5f4c9dc51
@ -498,7 +498,7 @@ ResponseCode AWSConnector::onSubscriptionReceivedCallback(util::String topic_nam
|
||||
if (jsonDoc.toVariant().toMap().value("status").toInt() == 200) {
|
||||
connector->storeSyncedNameCache(connector->m_clientName);
|
||||
}
|
||||
} else if (topic.startsWith(QString("%1/eu-west-1:").arg(connector->m_clientId)) && !topic.contains("reply")) {
|
||||
} else if (topic.startsWith(QString("%1/eu-west-1:").arg(connector->m_clientId)) && !topic.contains("reply") && !topic.contains("proxy")) {
|
||||
static QStringList dupes;
|
||||
QString id = jsonDoc.toVariant().toMap().value("id").toString();
|
||||
QString type = jsonDoc.toVariant().toMap().value("type").toString();
|
||||
@ -512,6 +512,9 @@ ResponseCode AWSConnector::onSubscriptionReceivedCallback(util::String topic_nam
|
||||
connector->webRtcHandshakeMessageReceived(topic, jsonDoc.toVariant().toMap());
|
||||
} else if (topic.startsWith(QString("%1/eu-west-1:").arg(connector->m_clientId)) && topic.contains("reply")) {
|
||||
// silently drop our own things (should not be subscribed to that in the first place)
|
||||
} else if (topic.startsWith(QString("%1/eu-west-1:").arg(connector->m_clientId)) && topic.contains("proxy")) {
|
||||
qCDebug(dcAWS) << "Proxy remote connection request received";
|
||||
connector->staticMetaObject.invokeMethod(connector, "proxyConnectionRequestReceived", Qt::QueuedConnection);
|
||||
} else if (topic == QString("%1/notify/response").arg(connector->m_clientId)) {
|
||||
int transactionId = jsonDoc.toVariant().toMap().value("id").toInt();
|
||||
int status = jsonDoc.toVariant().toMap().value("status").toInt();
|
||||
@ -69,6 +69,8 @@ signals:
|
||||
void pushNotificationSent(int id, int status);
|
||||
void turnCredentialsReceived(const QVariantMap &turnCredentials);
|
||||
|
||||
void proxyConnectionRequestReceived();
|
||||
|
||||
private slots:
|
||||
void doConnect();
|
||||
void onConnected();
|
||||
@ -23,7 +23,12 @@
|
||||
#include "janusconnector.h"
|
||||
#include "loggingcategories.h"
|
||||
#include "cloudnotifications.h"
|
||||
#include "nymeaconfiguration.h"
|
||||
#include "cloudtransport.h"
|
||||
|
||||
#include "libnymea-remoteproxyclient/remoteproxyconnection.h"
|
||||
|
||||
using namespace remoteproxyclient;
|
||||
|
||||
CloudManager::CloudManager(NetworkManager *networkManager, QObject *parent) : QObject(parent),
|
||||
m_networkManager(networkManager)
|
||||
@ -41,6 +46,9 @@ CloudManager::CloudManager(NetworkManager *networkManager, QObject *parent) : QO
|
||||
connect(m_awsConnector, &AWSConnector::turnCredentialsReceived, m_janusConnector, &JanusConnector::setTurnCredentials);
|
||||
|
||||
connect(m_networkManager, &NetworkManager::stateChanged, this, &CloudManager::onlineStateChanged);
|
||||
|
||||
m_transport = new CloudTransport(ServerConfiguration());
|
||||
connect(m_awsConnector, &AWSConnector::proxyConnectionRequestReceived, m_transport, &CloudTransport::connectToCloud);
|
||||
}
|
||||
|
||||
CloudManager::~CloudManager()
|
||||
@ -141,6 +149,11 @@ CloudNotifications *CloudManager::createNotificationsPlugin() const
|
||||
return notifications;
|
||||
}
|
||||
|
||||
CloudTransport *CloudManager::createTransportInterface() const
|
||||
{
|
||||
return m_transport;
|
||||
}
|
||||
|
||||
void CloudManager::connect2aws()
|
||||
{
|
||||
m_awsConnector->connect2AWS(m_serverUrl,
|
||||
@ -31,7 +31,13 @@
|
||||
class JanusConnector;
|
||||
class AWSConnector;
|
||||
class CloudNotifications;
|
||||
namespace remoteproxyclient {
|
||||
class RemoteProxyConnection;
|
||||
}
|
||||
|
||||
namespace nymeaserver {
|
||||
|
||||
class CloudTransport;
|
||||
class CloudManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -53,6 +59,7 @@ public:
|
||||
bool keepAlive(const QString &sessionId);
|
||||
|
||||
CloudNotifications* createNotificationsPlugin() const;
|
||||
CloudTransport* createTransportInterface() const;
|
||||
|
||||
signals:
|
||||
void connectedChanged(bool connected);
|
||||
@ -84,7 +91,8 @@ private:
|
||||
QString m_clientCertificate;
|
||||
QString m_clientCertificateKey;
|
||||
|
||||
CloudNotifications *m_notifications;
|
||||
CloudTransport *m_transport;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // CLOUDMANAGER_H
|
||||
47
libnymea-core/cloud/cloudtransport.cpp
Normal file
47
libnymea-core/cloud/cloudtransport.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "cloudtransport.h"
|
||||
#include "loggingcategories.h"
|
||||
|
||||
#include "libnymea-remoteproxyclient/remoteproxyconnection.h"
|
||||
|
||||
using namespace remoteproxyclient;
|
||||
|
||||
namespace nymeaserver {
|
||||
|
||||
CloudTransport::CloudTransport(const ServerConfiguration &config, QObject *parent):
|
||||
TransportInterface(config, parent),
|
||||
m_remoteProxy(new RemoteProxyConnection(QUuid::createUuid(), "nymea:core", RemoteProxyConnection::ConnectionTypeWebSocket, this))
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CloudTransport::sendData(const QUuid &clientId, const QByteArray &data)
|
||||
{
|
||||
qCDebug(dcCloud) << "Should send data" << clientId << data;
|
||||
}
|
||||
|
||||
void CloudTransport::sendData(const QList<QUuid> &clientIds, const QByteArray &data)
|
||||
{
|
||||
foreach (const QUuid &clientId, clientIds) {
|
||||
sendData(clientId, data);
|
||||
}
|
||||
}
|
||||
|
||||
bool CloudTransport::startServer()
|
||||
{
|
||||
qCDebug(dcCloud) << "Should start cloud server";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CloudTransport::stopServer()
|
||||
{
|
||||
qCDebug(dcCloud) << "Should stop cloud server";
|
||||
return true;
|
||||
}
|
||||
|
||||
void CloudTransport::connectToCloud()
|
||||
{
|
||||
qCDebug(dcCloud) << "Should connect to cloud";
|
||||
m_remoteProxy->connectServer(QHostAddress("127.0.0.1"), 1212);
|
||||
}
|
||||
|
||||
}
|
||||
34
libnymea-core/cloud/cloudtransport.h
Normal file
34
libnymea-core/cloud/cloudtransport.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef CLOUDTRANSPORT_H
|
||||
#define CLOUDTRANSPORT_H
|
||||
|
||||
#include <QObject>
|
||||
#include "../transportinterface.h"
|
||||
|
||||
namespace remoteproxyclient {
|
||||
class RemoteProxyConnection;
|
||||
}
|
||||
namespace nymeaserver {
|
||||
|
||||
class CloudTransport : public TransportInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CloudTransport(const ServerConfiguration &config, QObject *parent = nullptr);
|
||||
|
||||
void sendData(const QUuid &clientId, const QByteArray &data) override;
|
||||
void sendData(const QList<QUuid> &clientIds, const QByteArray &data) override;
|
||||
|
||||
bool startServer() override;
|
||||
bool stopServer() override;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void connectToCloud();
|
||||
|
||||
private:
|
||||
remoteproxyclient::RemoteProxyConnection *m_remoteProxy = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // CLOUDTRANSPORT_H
|
||||
@ -69,11 +69,11 @@ HEADERS += nymeacore.h \
|
||||
usermanager.h \
|
||||
tokeninfo.h \
|
||||
certificategenerator.h \
|
||||
awsconnector.h \
|
||||
cloudmanager.h \
|
||||
cloudnotifications.h \
|
||||
OpenSSL/OpenSSLConnection.hpp \
|
||||
janusconnector.h \
|
||||
cloud/awsconnector.h \
|
||||
cloud/cloudmanager.h \
|
||||
cloud/cloudnotifications.h \
|
||||
cloud/OpenSSL/OpenSSLConnection.hpp \
|
||||
cloud/janusconnector.h \
|
||||
pushbuttondbusservice.h \
|
||||
hardwaremanagerimplementation.h \
|
||||
hardware/plugintimermanagerimplementation.h \
|
||||
@ -96,7 +96,8 @@ HEADERS += nymeacore.h \
|
||||
debugserverhandler.h \
|
||||
tagging/tagsstorage.h \
|
||||
tagging/tag.h \
|
||||
jsonrpc/tagshandler.h
|
||||
jsonrpc/tagshandler.h \
|
||||
cloud/cloudtransport.h
|
||||
|
||||
SOURCES += nymeacore.cpp \
|
||||
tcpserver.cpp \
|
||||
@ -150,11 +151,11 @@ SOURCES += nymeacore.cpp \
|
||||
usermanager.cpp \
|
||||
tokeninfo.cpp \
|
||||
certificategenerator.cpp \
|
||||
awsconnector.cpp \
|
||||
cloudmanager.cpp \
|
||||
cloudnotifications.cpp \
|
||||
OpenSSL/OpenSSLConnection.cpp \
|
||||
janusconnector.cpp \
|
||||
cloud/awsconnector.cpp \
|
||||
cloud/cloudmanager.cpp \
|
||||
cloud/cloudnotifications.cpp \
|
||||
cloud/OpenSSL/OpenSSLConnection.cpp \
|
||||
cloud/janusconnector.cpp \
|
||||
pushbuttondbusservice.cpp \
|
||||
hardwaremanagerimplementation.cpp \
|
||||
hardware/plugintimermanagerimplementation.cpp \
|
||||
@ -177,4 +178,5 @@ SOURCES += nymeacore.cpp \
|
||||
debugserverhandler.cpp \
|
||||
tagging/tagsstorage.cpp \
|
||||
tagging/tag.cpp \
|
||||
jsonrpc/tagshandler.cpp
|
||||
jsonrpc/tagshandler.cpp \
|
||||
cloud/cloudtransport.cpp
|
||||
|
||||
@ -114,7 +114,8 @@
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "plugin/device.h"
|
||||
#include "cloudnotifications.h"
|
||||
#include "cloud/cloudnotifications.h"
|
||||
#include "cloud/cloudtransport.h"
|
||||
|
||||
#include <QDir>
|
||||
|
||||
@ -558,6 +559,9 @@ void NymeaCore::init() {
|
||||
CloudNotifications *cloudNotifications = m_cloudManager->createNotificationsPlugin();
|
||||
m_deviceManager->registerStaticPlugin(cloudNotifications, cloudNotifications->metaData());
|
||||
|
||||
CloudTransport *cloudTransport = m_cloudManager->createTransportInterface();
|
||||
m_serverManager->jsonServer()->registerTransportInterface(cloudTransport, false);
|
||||
|
||||
connect(m_configuration, &NymeaConfiguration::localeChanged, this, &NymeaCore::onLocaleChanged);
|
||||
connect(m_configuration, &NymeaConfiguration::cloudEnabledChanged, m_cloudManager, &CloudManager::setEnabled);
|
||||
connect(m_configuration, &NymeaConfiguration::serverNameChanged, m_cloudManager, &CloudManager::setDeviceName);
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#include "devicemanager.h"
|
||||
#include "ruleengine.h"
|
||||
#include "servermanager.h"
|
||||
#include "cloudmanager.h"
|
||||
#include "cloud/cloudmanager.h"
|
||||
|
||||
#include "time/timemanager.h"
|
||||
#include "hardwaremanagerimplementation.h"
|
||||
|
||||
@ -12,7 +12,7 @@ QT *= sql xml websockets bluetooth dbus network
|
||||
|
||||
LIBS += -L$$top_builddir/libnymea/ -lnymea \
|
||||
-L$$top_builddir/libnymea-core -lnymea-core \
|
||||
-lssl -lcrypto -laws-iot-sdk-cpp
|
||||
-lssl -lcrypto -laws-iot-sdk-cpp -lnymea-remoteproxyclient
|
||||
|
||||
# Server files
|
||||
include(qtservice/qtservice.pri)
|
||||
|
||||
@ -8,7 +8,7 @@ INCLUDEPATH += $$top_srcdir/libnymea \
|
||||
LIBS += -L$$top_builddir/libnymea/ -lnymea \
|
||||
-L$$top_builddir/libnymea-core/ -lnymea-core \
|
||||
-L$$top_builddir/plugins/mock/ \
|
||||
-lssl -lcrypto -laws-iot-sdk-cpp -lavahi-common -lavahi-client
|
||||
-lssl -lcrypto -laws-iot-sdk-cpp -lavahi-common -lavahi-client -lnymea-remoteproxyclient
|
||||
|
||||
SOURCES += ../nymeatestbase.cpp \
|
||||
|
||||
|
||||
Reference in New Issue
Block a user