blob: ce85c0cc7d208fb350d890ce88139e0eaef7840e (
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
|
#include <QtCore/QDebug>
#include "sappeer.h"
#include "sapconnection.h"
#include "sapsocket.h"
SAPSocket::SAPSocket(SAPConnection *conn, int sessionId) :
QObject(conn), _sessionId(sessionId), _open(false)
{
}
SAPPeer * SAPSocket::peer()
{
return connection()->peer();
}
SAPConnection * SAPSocket::connection()
{
return static_cast<SAPConnection*>(parent());
}
bool SAPSocket::isOpen() const
{
return _open;
}
bool SAPSocket::messageAvailable() const
{
return !_in.empty();
}
QByteArray SAPSocket::receive()
{
if (!_in.empty()) {
return _in.dequeue();
} else {
return QByteArray();
}
}
bool SAPSocket::send(const QByteArray &data)
{
return peer()->writeToSession(_sessionId, data);
}
void SAPSocket::setOpen(bool open)
{
_open = open;
}
void SAPSocket::acceptIncomingData(const QByteArray &data)
{
if (data.isEmpty()) return;
_in.enqueue(data);
emit messageReceived();
}
int SAPSocket::sessionId() const
{
return _sessionId;
}
|