-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconnection.h
67 lines (57 loc) · 1.79 KB
/
connection.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
/*************************************************************************
**
** (C) Copyright 2013 Reach Technology Inc.
**
** This code is protected by international copyright laws. This file may
** only be used in accordance with a license and cannot be used on
** hardware other than supplied by Reach Technology Inc. We appreciate
** your understanding and fairness.
**
*************************************************************************/
#ifndef CONNECTION_H
#define CONNECTION_H
#include <QObject>
#include <QtNetwork>
#include <QTimer>
#include "systemdefs.h"
class Connection : public QObject
{
Q_OBJECT
public:
explicit Connection(QObject *parent = 0);
~Connection();
public slots:
void sendMessage(const QString &message);
void updateValue(const QString &objectName, const QString &property, const QVariant &value);
void enableHeartbeat(int);
void enableHeartbeat(int, QString, QString);
void disableHeartbeat();
void enableLookupAck();
void disableLookupAck();
signals:
void messageAvailable(const QByteArray &message);
void readyToSend();
void notReadyToSend();
void noHeartbeat();
void heartbeat();
void lookupAckChanged(bool);
private slots:
void onSocketConnected();
void onSocketDisconnected();
void onSocketError(QLocalSocket::LocalSocketError);
void onSocketReadyRead();
void onSocketStateChange(QLocalSocket::LocalSocketState );
void tryConnect();
void onConnectTimerTimeout();
void onHeartbeatTimerTimeout();
private:
QLocalSocket *m_socket;
QTimer *m_connectTimer;
bool m_enableAck;
bool m_hearbeat;
QString m_heartbeatText;
QString m_heartbeatResponseText;
int m_heartbeat_interval;
QTimer *m_hearbeatTimer;
};
#endif // CONNECTION_H