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.
Michael Zanetti 22dd3fe27d intermediate commit.
Working pretty well now. No cleanup done. some broken menu entries related to
connect.

TBC
2019-02-06 03:00:43 +01:00

58 lines
2.3 KiB
C++

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (C) 2017 Simon Stuerz <simon.stuerz@guh.io> *
* *
* This file is part of nymea:app. *
* *
* nymea:app 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 3 of the License. *
* *
* nymea:app 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 nymea:app. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef WEBSOCKETTRANSPORT_H
#define WEBSOCKETTRANSPORT_H
#include <QObject>
#include <QWebSocket>
#include "nymeatransportinterface.h"
class WebsocketTransportFactory: public NymeaTransportInterfaceFactory
{
public:
NymeaTransportInterface* createTransport(QObject *parent = nullptr) const override;
QStringList supportedSchemes() const override;
};
class WebsocketTransport: public NymeaTransportInterface
{
Q_OBJECT
public:
explicit WebsocketTransport(QObject *parent = nullptr);
bool connect(const QUrl &url) override;
QUrl url() const override;
ConnectionState connectionState() const override;
void disconnect() override;
void sendData(const QByteArray &data) override;
void ignoreSslErrors(const QList<QSslError> &errors) override;
private:
QUrl m_url;
QWebSocket *m_socket;
private slots:
void onTextMessageReceived(const QString &data);
};
#endif // WEBSOCKETTRANSPORT_H