-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQmlWebSocket.h
More file actions
42 lines (38 loc) · 1.21 KB
/
QmlWebSocket.h
File metadata and controls
42 lines (38 loc) · 1.21 KB
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
37
38
39
40
41
42
/*
* @Author: chaiyukuan
* @LastEditors: chaiyukuan
*/
#pragma once
#include <QtWebSockets/QWebSocket>
QT_FORWARD_DECLARE_CLASS(QSslPreSharedKeyAuthenticator)
class QmlWebSocket : public QObject {
Q_OBJECT
public:
explicit QmlWebSocket(QObject* parent = Q_NULLPTR);
virtual ~QmlWebSocket();
public Q_SLOTS:
void connect(const QString& url);
void send(const QString& msg);
void connected();
void disconnected();
void stateChanged(QAbstractSocket::SocketState state);
void readChannelFinished();
void textFrameReceived(const QString& frame, bool isLastFrame);
void binaryFrameReceived(const QByteArray& frame, bool isLastFrame);
void textMessageReceived(const QString& message);
void binaryMessageReceived(const QByteArray& message);
void error2(QAbstractSocket::SocketError error);
void pong(quint64 elapsedTime, const QByteArray& payload);
void bytesWritten(qint64 bytes);
void sslErrors(const QList<QSslError>& errors);
void preSharedKeyAuthenticationRequired(
QSslPreSharedKeyAuthenticator* authenticator);
Q_SIGNALS:
void close();
void error(const QString& errorMessage);
void message(const QString& msg);
void open();
private:
QWebSocket _websocket;
bool connect_{false};
};