Re-implemented ActiveSessionSocket. Still doesn't work, though.
[aesalon.git] / src / gui / ActiveSessionSocket.cpp
blobabb340d266b3ceffa630268908e5fa76b2ddb996
1 #include "ActiveSessionSocket.h"
2 #include "ActiveSessionSocket.moc"
4 namespace Aesalon {
5 namespace GUI {
7 ActiveSessionSocket::ActiveSessionSocket(QString host, int port, Platform::Memory *memory) : memory(memory) {
8 socket = new QTcpSocket();
10 socket->connectToHost(host, port);
11 connect(socket, SIGNAL(readyRead()), this, SLOT(handle_data()));
12 connect(socket, SIGNAL(connected()), this, SLOT(reemit_connected()));
15 ActiveSessionSocket::~ActiveSessionSocket() {
18 void ActiveSessionSocket::handle_data() {
19 QByteArray data = socket->readAll();
20 while(data.length()) {
21 QString string = data;
22 data.remove(0, string.length());
23 Platform::Event *event = Platform::Event::deserialize(string.toStdString());
24 if(event) memory->handle_event(event);
28 } // namespace GUI
29 } // namespace Aesalon