-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnector.h
44 lines (38 loc) · 945 Bytes
/
connector.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
#ifndef CONNECTOR_H
#define CONNECTOR_H
#include <QObject>
#include <QAbstractSocket>
#include <QUdpSocket>
#include <QTcpSocket>
#include <QMutexLocker>
#include "UICmdResponse.h"
class Connector : public QObject
{
Q_OBJECT
public:
enum Operation
{
OP_SENDING,
OP_RECEIVING,
OP_SUCCEED,
OP_FAILED
};
public:
Connector(QObject *parent = 0);
bool connectToServer(const QString &addr, quint16 port);
bool disconnectFromServer();
bool send(const QString &command);
bool send(const QString &command, QString &result);
bool send(const QString &command, au::UICmdResponse &response);
signals:
void connectionConnected();
void connectionDisconnected();
void connectionOperating(const QString &command, int op);
public slots:
void socketConnect();
private:
QAbstractSocket *absSocket;
QUdpSocket *udpSocket;
QMutex mutex;
};
#endif // CONNECTOR_H