This repository has been archived on 2026-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
powersync-core/server/cloud/cloudconnectionhandler.cpp
Simon Stürz 69a8d881d2 add cloud JSON RPC
basic functionality working
2019-04-01 20:48:17 +02:00

95 lines
3.5 KiB
C++

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2016 Simon Stürz <simon.stuerz@guh.guru> *
* *
* This file is part of guh. *
* *
* Guh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, version 2 of the License. *
* *
* Guh is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "cloudconnectionhandler.h"
#include "loggingcategories.h"
#include "guhcore.h"
namespace guhserver {
CloudConnectionHandler::CloudConnectionHandler(QObject *parent) :
CloudJsonHandler(parent)
{
}
QString CloudConnectionHandler::nameSpace() const
{
return "Connection";
}
void CloudConnectionHandler::processGetConnections(const QVariantMap &params)
{
Q_UNUSED(params)
}
void CloudConnectionHandler::processGetTunnels(const QVariantMap &params)
{
foreach (const QVariant &tunnelVariant, params.value("tunnel").toList()) {
QVariantMap tunnelMap = tunnelVariant.toMap();
QUuid tunnelId = tunnelMap.value("id").toUuid();
QUuid serverId = tunnelMap.value("serverConnection").toMap().value("id").toUuid();
QUuid clientId = tunnelMap.value("clientConnection").toMap().value("id").toUuid();
GuhCore::instance()->cloudManager()->onTunnelAdded(tunnelId, serverId, clientId);
}
}
void CloudConnectionHandler::processSendData(const QVariantMap &params)
{
Q_UNUSED(params)
}
void CloudConnectionHandler::processConnectionAdded(const QVariantMap &params)
{
Q_UNUSED(params)
}
void CloudConnectionHandler::processConnectionRemoved(const QVariantMap &params)
{
Q_UNUSED(params)
}
void CloudConnectionHandler::processTunnelAdded(const QVariantMap &params)
{
QVariantMap tunnelMap = params.value("tunnel").toMap();
QUuid tunnelId = tunnelMap.value("id").toUuid();
QUuid serverId = tunnelMap.value("serverConnection").toMap().value("id").toUuid();
QUuid clientId = tunnelMap.value("clientConnection").toMap().value("id").toUuid();
GuhCore::instance()->cloudManager()->onTunnelAdded(tunnelId, serverId, clientId);
}
void CloudConnectionHandler::processTunnelRemoved(const QVariantMap &params)
{
QUuid tunnelId = params.value("tunnelId").toUuid();
GuhCore::instance()->cloudManager()->onTunnelRemoved(tunnelId);
}
void CloudConnectionHandler::processDataReceived(const QVariantMap &params)
{
QUuid tunnelId = params.value("tunnelId").toUuid();
GuhCore::instance()->cloudManager()->onCloudDataReceived(tunnelId, params.value("data").toMap());
}
}