summaryrefslogtreecommitdiff
path: root/sapsocket.h
blob: e1a92146611990d6b77b98394ca697416b158b2f (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
#ifndef SAPSOCKET_H
#define SAPSOCKET_H

#include <QtCore/QObject>
#include <QtCore/QQueue>

class SAPConnection;
class SAPPeer;

class SAPSocket : public QObject
{
	Q_OBJECT

	SAPSocket(SAPConnection *conn, int sessionId);

public:
	SAPPeer *peer();
	SAPConnection *connection();

	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;

private:
	int _sessionId;
	bool _open;
	QQueue<QByteArray> _in;

	friend class SAPPeer;
};

#endif // SAPSOCKET_H