-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsession.h
61 lines (44 loc) · 1.19 KB
/
session.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef SESSION_H
#define SESSION_H
#include <QString>
#include <QVector>
#include <QPointer>
#include <QObject>
#include <QWebSocket>
#include <QJsonObject>
#include <QJsonDocument>
#include <QUdpSocket>
class Session : public QObject
{
Q_OBJECT
public:
Session(QWebSocket * socket);
~Session();
QWebSocket *GetSocket();
void SendClientError(const QString error);
void SendData(const QString method, const QJsonObject data = QJsonObject());
void SetId(QString id);
QString GetId();
void SetRoomId(QString roomId);
QString GetRoomId();
void SetUdpPort(const quint16 i);
quint16 GetUdpPort() const;
void SendMessage(const QByteArray b, const bool udpPreferred);
signals:
void socketConnected();
void socketDisconnected();
void socketBytesWritten(qint64 bytes);
void socketTextMessageReceived(QString message);
public slots:
void connected();
void disconnected();
void bytesWritten(qint64 bytes);
void textMessageReceived(QString message);
private:
QWebSocket * _socket;
QString _id;
QString _roomId;
QUdpSocket * _udpSocket;
quint16 _udpPort; //UDP supported if port > 0
};
#endif // SESSION_H