mirror of https://github.com/nymea/nymea.git
Support providing a custom remote proxy url
parent
153774ae24
commit
309240ed47
|
|
@ -489,6 +489,7 @@ void AWSConnector::onPublishReceived(const QString &topic, const QByteArray &pay
|
|||
} else if (topic.startsWith(QString("%1/eu-west-1:").arg(m_clientId)) && topic.contains("proxy")) {
|
||||
QString token = jsonDoc.toVariant().toMap().value("token").toString();
|
||||
QString timestamp = jsonDoc.toVariant().toMap().value("timestamp").toString();
|
||||
QString serverUrl = jsonDoc.toVariant().toMap().value("serverUrl").toString();
|
||||
static QHash<QString, QDateTime> dupes;
|
||||
QString packetId = topic + token + timestamp;
|
||||
if (dupes.contains(packetId)) {
|
||||
|
|
@ -502,7 +503,7 @@ void AWSConnector::onPublishReceived(const QString &topic, const QByteArray &pay
|
|||
}
|
||||
}
|
||||
qCDebug(dcAWS) << "Proxy remote connection request received";
|
||||
proxyConnectionRequestReceived(token, timestamp);
|
||||
proxyConnectionRequestReceived(token, timestamp, serverUrl);
|
||||
} else if (topic == QString("%1/notify/response").arg(m_clientId)) {
|
||||
int transactionId = jsonDoc.toVariant().toMap().value("id").toInt();
|
||||
int status = jsonDoc.toVariant().toMap().value("status").toInt();
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ signals:
|
|||
void pushNotificationSent(int id, int status);
|
||||
void turnCredentialsReceived(const QVariantMap &turnCredentials);
|
||||
|
||||
void proxyConnectionRequestReceived(const QString &token, const QString &nonce);
|
||||
void proxyConnectionRequestReceived(const QString &token, const QString &nonce, const QString &serverUrl);
|
||||
|
||||
private slots:
|
||||
void doConnect();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace nymeaserver {
|
|||
CloudTransport::CloudTransport(const ServerConfiguration &config, QObject *parent):
|
||||
TransportInterface(config, parent)
|
||||
{
|
||||
m_proxyUrl = QUrl("wss://remoteproxy.nymea.io");
|
||||
m_defaultProxyUrl = "wss://remoteproxy.nymea.io";
|
||||
}
|
||||
|
||||
void CloudTransport::sendData(const QUuid &clientId, const QByteArray &data)
|
||||
|
|
@ -75,9 +75,10 @@ bool CloudTransport::stopServer()
|
|||
return true;
|
||||
}
|
||||
|
||||
void CloudTransport::connectToCloud(const QString &token, const QString &nonce)
|
||||
void CloudTransport::connectToCloud(const QString &token, const QString &nonce, const QString &serverUrl)
|
||||
{
|
||||
qCDebug(dcCloud()) << "Connecting to remote proxy server" << m_proxyUrl.toString();
|
||||
QString proxyUrl = serverUrl.isEmpty() ? m_defaultProxyUrl : serverUrl;
|
||||
qCDebug(dcCloud()) << "Connecting to remote proxy server" << proxyUrl;
|
||||
|
||||
ConnectionContext context;
|
||||
context.clientId = QUuid::createUuid();
|
||||
|
|
@ -93,7 +94,7 @@ void CloudTransport::connectToCloud(const QString &token, const QString &nonce)
|
|||
connect(context.proxyConnection, &RemoteProxyConnection::remoteConnectionEstablished, this, &CloudTransport::transportConnected);
|
||||
connect(context.proxyConnection, &RemoteProxyConnection::disconnected, this, &CloudTransport::transportDisconnected);
|
||||
|
||||
context.proxyConnection->connectServer(m_proxyUrl);
|
||||
context.proxyConnection->connectServer(QUrl(proxyUrl));
|
||||
}
|
||||
|
||||
void CloudTransport::remoteConnectionStateChanged(RemoteProxyConnection::State state)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public:
|
|||
signals:
|
||||
|
||||
public slots:
|
||||
void connectToCloud(const QString &token, const QString &nonce);
|
||||
void connectToCloud(const QString &token, const QString &nonce, const QString &serverUrl);
|
||||
|
||||
private slots:
|
||||
void remoteConnectionStateChanged(remoteproxyclient::RemoteProxyConnection::State state);
|
||||
|
|
@ -54,7 +54,7 @@ private slots:
|
|||
void transportDisconnected();
|
||||
|
||||
private:
|
||||
QUrl m_proxyUrl;
|
||||
QString m_defaultProxyUrl;
|
||||
|
||||
class ConnectionContext {
|
||||
public:
|
||||
|
|
|
|||
Loading…
Reference in New Issue