From 8f295735da46c61581511d383c6c5cbd73e77cce Mon Sep 17 00:00:00 2001 From: dorian Date: Mon, 7 Oct 2019 19:52:39 +0200 Subject: [PATCH] the extensions are also using the update protocol now --- headers/baseconn.h | 2 ++ sources/baseconn.cpp | 11 ++++++++++- sources/climbingrace.cpp | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/headers/baseconn.h b/headers/baseconn.h index 467eafe..4590979 100644 --- a/headers/baseconn.h +++ b/headers/baseconn.h @@ -110,6 +110,8 @@ public slots: Q_INVOKABLE bool refreshConnections(); + void setConnections(QVariantList connections); + // functions for the qml adapter QString getIP() const; void setIP(const QString &ipAdress); diff --git a/sources/baseconn.cpp b/sources/baseconn.cpp index 3bb8a16..4531f4f 100644 --- a/sources/baseconn.cpp +++ b/sources/baseconn.cpp @@ -50,13 +50,15 @@ bool BaseConn::init() { this->setState("connected"); // init remote session - QJsonArray updateSubs = {"onRaceStateChanged", "onTimersChanged"}; + QJsonArray updateSubs = {"onRaceStateChanged", "onTimersChanged", "onExtensionConnectionsChanged"}; QJsonObject sessionParams = {{"updateSubs", updateSubs}}; if(this->sendCommand(1, sessionParams)["status"] != 200) { return false; } + this->refreshConnections(); + return true; } @@ -385,3 +387,10 @@ QVariant BaseConn::getConnections() { //QVariantList conns = {conn, conn1}; //return conns; } + +void BaseConn::setConnections(QVariantList connections) { + if(this->connections != connections){ + this->connections = connections; + emit this->connectionsChanged(); + } +} diff --git a/sources/climbingrace.cpp b/sources/climbingrace.cpp index 62685dc..ba39c77 100644 --- a/sources/climbingrace.cpp +++ b/sources/climbingrace.cpp @@ -36,7 +36,7 @@ ClimbingRace::ClimbingRace(QObject *parent) : QObject(parent) this->baseStationSyncTimer->setInterval(1000); this->baseStationSyncTimer->setSingleShot(true); this->baseStationSyncTimer->connect(this->baseStationSyncTimer, &QTimer::timeout, this, &ClimbingRace::syncWithBaseStation); - this->baseStationSyncTimer->start(); + //this->baseStationSyncTimer->start(); this->timerTextRefreshTimer = new QTimer(this); this->timerTextRefreshTimer->setInterval(1); @@ -284,6 +284,12 @@ void ClimbingRace::handleBaseStationUpdate(QVariant data) { this->refreshRemoteTimers(data.toMap()["data"].toList()); break; } + case 9002: + { + // the extension connections have changed + this->baseConn->setConnections(data.toMap()["data"].toList()); + break; + } } }