#include "app.h" App::App(Stomp* st) { st_ = st; st_->connectRequest("sdi.hevs.ch", 61614, "/", "sdi10", "809c02f36becb0868da98761fe3209f6"); st_->sendRequest("/topic/sdi10.gem.command", "right"); st_->subscribeRequest("/topic/sdi10.gem.field", 1); } void App::connectConfirmation(bool success, QString version) { } void App::sendConfirmation(bool success) { } void App::subscribeConfirmation(bool success) { st_->sendRequest("/topic/sdi10.gem.command", "up"); } void App::receiveIndication(int id, QString destination, QString body) { //qDebug() << "Indication " << id << " : " << destination << Qt::endl << body << Qt::endl; if(destination.contains("field")){ fillField(body); } computeMove(); } void App::disconnectConfirmation() { } void App::disconnectIndication() { } void App::addGem(int x, int y, int pts) { Gem g; g.x = x; g.y = y; g.pts = pts; g.relativePts = computeRelativePts(g); gems_.append(g); } void App::printGem() { for (Gem g: gems_) { qDebug() << g.x << ":" << g.y << " - " << g.pts << Qt::endl; } } void App::fillField(QString body) { int x = 0; int y = 0; gems_.clear(); for(int i = 0; i