-
Notifications
You must be signed in to change notification settings - Fork 0
/
qt_json_socket_lib.h
84 lines (57 loc) · 1.64 KB
/
qt_json_socket_lib.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef QT_JSON_SOCKET_LIB_H
#define QT_JSON_SOCKET_LIB_H
#include "qt_json_socket_lib_global.h"
#include <QTcpSocket>
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
#include <QString>
#include <QMetaMethod>
class QT_JSON_SOCKET_LIBSHARED_EXPORT Qt_Json_Socket_Lib:public QObject
{
Q_OBJECT
public:
Qt_Json_Socket_Lib();
~Qt_Json_Socket_Lib();
//클라이언트 소켓 생성
bool make_QTcpSocket();
//소켓
void set_socket(QTcpSocket* sock);
//소켓 받기
QTcpSocket* get_socket();
//QByteArray 전송
bool send_QByteArray(QByteArray arr);
//QByteArray 수신
QByteArray recv_QByteArray();
//Json전송
bool send_Json(QJsonObject obj);
//Json수신
QJsonDocument recv_Json();
//connect 타임아웃
void set_connect_timeout(qint64 t);
//send 타임아웃 세팅
void set_send_timeout(qint64 t);
//recv 타임아웃 세팅
void set_recv_timeout(qint64 t);
//connect
void connect_server(QHostAddress& a, qint64 port);
//disconnect
void disconnect_server();
void disconnect_socket();
//소켓디스크립터 삭제
void delete_QTcpSocket();
private slots:
//소켓으로부터 disconnect 시그널을 받아서 disconnect_from_socket()으로 emit함
void disconnect_slot();
Q_SIGNALS:
//만약 disconnect_가 됬을 경우
void disconnect_from_socket();
private:
QTcpSocket* sock__;
QJsonDocument doc__;
QJsonObject obj__;
qint64 send_timeout__;
qint64 recv_timeout__;
qint64 connect_timeout__;
};
#endif // QT_JSON_SOCKET_LIB_H