stec-platform
autoqtcpsocket.h
1 #ifndef AUTOQTCPSOCKET_H
2 #define AUTOQTCPSOCKET_H
3 
4 
5 
6 #include <QByteArray>
7 #include <QObject>
8 #include <QString>
9 #include <QTcpSocket>
10 #include <QTimer>
11 #include <QVariant>
12 #include <QVariantList>
13 #include <QElapsedTimer>
14 
15 #include <platform_global.h>
16 #include <transceiver.h>
17 
18 
19 namespace ADI {
20 
21 
22 
23 /*
24  * \ingroup platform
25  * @brief AutoQTcpSocket
26  *
27  * This provides all the socket signalling and communication transport for, both, client and daemons.
28  */
29 class PLATFORMSHARED_EXPORT AutoQTcpSocket : public QObject, private cyo::Transceiver
30 {
31  Q_OBJECT
32 
33 private :
34 
35  QTcpSocket *xm;
36  QString interfaceAddress;
37  int servicePort;
38  QTimer *timer;
39  QTimer *timerWatchDog;
40  QElapsedTimer elapsed;
41 
42  qint32 blockSize;
43  bool doDaemon;
44  bool doClient;
45 
46  QList<QString> selfAdrList();
47 
48 
49 public:
51  AutoQTcpSocket(QString ipAddress, int port, bool dodaemon, QObject *parent = nullptr);
52 
54  AutoQTcpSocket(QTcpSocket *XM, QObject *parent = nullptr);
55 
57  virtual ~AutoQTcpSocket();
58 
60  void SendQVList( QVariantList &vl );
61 
63  bool SideChannelCheck(const QVariantList &message);
64 
65  virtual void userDataPacket(const QVariantList &msg);
66 
67 public slots :
69  void Disconnect();
70 
71  // occurs when a socket connection is made
72  void Connect();
73 
75  void Error(QAbstractSocket::SocketError socketError);
76 
77 signals :
78 
80  void SignedConnected(QString, int);
81 
83  void SignedDisconnected(QString, int);
84 
86  void PacketReady(QString, int, QVariantList va);
87 
88 private slots :
89 
91  void SlotTimerout();
92 
94  void SlotTimerWatchdog();
95 
97  void DataReady();
98 
100  void SendPacket(QVariantList ba);
101 };
102 }
103 #endif // AUTOQTCPSOCKET_H
Definition: autoqtcpsocket.h:30
void SignedConnected(QString, int)
tells when connected to this, with peer and port
void SignedDisconnected(QString, int)
tells when disnected to this, with peer and port
void PacketReady(QString, int, QVariantList va)
Receives a slot from the other side.
The Transceiver class interprocess commununication transceiver.
Definition: transceiver.h:23
Definition: autoqtcpdistribution.cpp:10