mirror of
https://gitlab.com/comunic/comunicwatcher
synced 2024-11-24 14:29:27 +00:00
Parse WS messages
This commit is contained in:
parent
ff955398b9
commit
68d8d1b5c7
11
wsclient.cpp
11
wsclient.cpp
@ -1,4 +1,5 @@
|
||||
#include <QTimer>
|
||||
#include <QJsonDocument>
|
||||
|
||||
#include "apirequest.h"
|
||||
#include "wsclient.h"
|
||||
@ -50,4 +51,14 @@ void WsClient::onConnected()
|
||||
void WsClient::onMessage(const QString &msg)
|
||||
{
|
||||
qDebug() << "WS message: " << msg;
|
||||
|
||||
auto obj = QJsonDocument::fromJson(msg.toUtf8()).object();
|
||||
auto title = obj.value("title").toString();
|
||||
auto value = obj.value("data").toInt(-1);
|
||||
|
||||
if(title == "number_notifs")
|
||||
emit newNumberNotifs(value);
|
||||
|
||||
else if(title == "number_unread_conversations")
|
||||
emit newNumberConvs(value);
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ public slots:
|
||||
void startConnect();
|
||||
|
||||
signals:
|
||||
void newNumberNotifs(int num);
|
||||
void newNumberConvs(int num);
|
||||
|
||||
private slots:
|
||||
void onConnectionError();
|
||||
|
Loading…
Reference in New Issue
Block a user