File: websocketiodevice.h

package info (click to toggle)
qt6-remoteobjects 6.10.2-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 3,812 kB
  • sloc: cpp: 20,894; sh: 29; makefile: 26
file content (36 lines) | stat: -rw-r--r-- 806 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright (C) 2019 Ford Motor Company
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#ifndef WEBSOCKETIODEVICE_H
#define WEBSOCKETIODEVICE_H

#include <QBuffer>
#include <QIODevice>
#include <QPointer>
#include <QWebSocket>

class WebSocketIoDevice : public QIODevice
{
    Q_OBJECT
public:
    WebSocketIoDevice(QWebSocket *webSocket, QObject *parent = nullptr);

signals:
    void disconnected();

    // QIODevice interface
public:
    qint64 bytesAvailable() const override;
    bool isSequential() const override;
    void close() override;

protected:
    qint64 readData(char *data, qint64 maxlen) override;
    qint64 writeData(const char *data, qint64 len) override;

private:
    QPointer<QWebSocket> m_socket;
    QByteArray m_buffer;
};

#endif // WEBSOCKETIODEVICE_H