2 #include "ActiveSessionSocket.h"
3 #include "ActiveSessionSocket.moc"
8 ActiveSessionSocket::ActiveSessionSocket(QString host
, int port
, Platform::Memory
*memory
) : memory(memory
) {
9 socket
= new QTcpSocket();
11 socket
->connectToHost(host
, port
);
12 connect(socket
, SIGNAL(readyRead()), this, SLOT(handle_data()));
13 connect(socket
, SIGNAL(connected()), this, SLOT(reemit_connected()));
14 connect(socket
, SIGNAL(disconnected()), this, SLOT(reemit_disconnected()));
17 ActiveSessionSocket::~ActiveSessionSocket() {
20 void ActiveSessionSocket::handle_data() {
21 QByteArray data
= socket
->readAll();
23 while(data
.length()) {
24 QString string
= data
;
25 data
.remove(0, string
.length());
26 Platform::Event
*event
= Platform::Event::deserialize(string
.toStdString());
28 memory
->handle_event(event
);
29 emit
event_received(event
);
36 } // namespace Aesalon