There is now a partially functional block display in the aesalon GUI.
[aesalon.git] / src / gui / ActiveSessionSocket.cpp
blob4a193a671b04598e36c9ac1f1fe04869a425c47f
1 #include <iostream>
2 #include "ActiveSessionSocket.h"
3 #include "ActiveSessionSocket.moc"
5 namespace Aesalon {
6 namespace GUI {
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();
22 QString str = data;
23 while(data.length()) {
24 QString string = data;
25 data.remove(0, string.length());
26 Platform::Event *event = Platform::Event::deserialize(string.toStdString());
27 if(event) {
28 memory->handle_event(event);
29 emit event_received(event);
30 delete event;
35 } // namespace GUI
36 } // namespace Aesalon