blob: 0452e9d2c11bf557752ff8e270b5b73f04ce8e8d (
plain)
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
|
#ifndef SAPSOCKET_H
#define SAPSOCKET_H
#include <QtCore/QObject>
#include <QtCore/QQueue>
#include <QtCore/QBasicTimer>
#include "sapchannelinfo.h"
class SAPConnection;
class SAPPeer;
class SAPSocket : public QObject
{
Q_OBJECT
SAPSocket(SAPConnection *conn, int sessionId, const SAPChannelInfo &chanInfo);
public:
SAPPeer *peer();
SAPConnection *connection();
SAPChannelInfo channelInfo() const;
bool isOpen() const;
bool messageAvailable() const;
QByteArray receive();
bool send(const QByteArray &data);
signals:
void connected();
void disconnected();
void messageReceived();
protected:
void setOpen(bool open);
void acceptIncomingData(const QByteArray &data);
int sessionId() const;
virtual void timerEvent(QTimerEvent *event) override;
private:
bool isReliable() const;
bool isWithSeqNum() const;
private:
const int _sessionId;
const SAPChannelInfo _info;
bool _open;
QQueue<QByteArray> _in;
QQueue<QByteArray> _out;
QBasicTimer _timer;
/** Outgoing sequence number */
quint16 _outLastSeqNum;
/** Last acknowledged sent message. */
quint16 _outLastAck;
/** Next expected incoming sequence number */
quint16 _inLastSeqNum;
/** Last acknowledged sequence number */
quint16 _inLastAck;
friend class SAPPeer;
};
#endif // SAPSOCKET_H
|