From 81fe1238505972c209c81f1c729ae910c275cfe9 Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Tue, 18 Nov 2003 18:27:35 +0000 Subject: [PATCH] El ControlClient ya puede recibir "frames" con el estado de la planta! :-D Esta hecho un poco a las patadas, pero asi puedo laburar un poco mas tranquilo sabiendo que no trabo el avance del cliente grafico. El Receiver se levanta cuando se crea el ControlClient, asi que todo lo que hay que hacer es mandar un comando /transmission/start/default/localhost/7528 para que empiece a transmitirnos el server (bueno, localhost si corre local). Se actualiza el ejemplo para tener de referencia (igual todo lo que hay que hacer es atender la signal_frame_received(const std::string& frame) que entrega el XML del frame recibido). --- Server/include/plaqui/server/controlclient.h | 9 +++++++++ Server/src/controlclient.cpp | 11 ++++++++++- Server/tests/client_test.cpp | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Server/include/plaqui/server/controlclient.h b/Server/include/plaqui/server/controlclient.h index 669fba4..f225240 100644 --- a/Server/include/plaqui/server/controlclient.h +++ b/Server/include/plaqui/server/controlclient.h @@ -30,6 +30,7 @@ #include "plaqui/server/command.h" #include "plaqui/server/connection.h" +#include "plaqui/server/receiver.h" // TODO TEMPRORAL #include namespace PlaQui { @@ -65,6 +66,9 @@ namespace Server { /// Señal para indicar que se recibió un error. SignalErrorReceived error_received; + /// Receptor del estado de la planta TODO Temporal. + Receiver receiver; + // Métodos. private: @@ -113,6 +117,11 @@ namespace Server { */ SignalErrorReceived& signal_error_received(void); + /** + * Obtiene la señal que avisa cuando se recibió un cuadro. + */ + Receiver::SignalFrameReceived& signal_frame_received(void); + }; } diff --git a/Server/src/controlclient.cpp b/Server/src/controlclient.cpp index 511def5..48ef328 100644 --- a/Server/src/controlclient.cpp +++ b/Server/src/controlclient.cpp @@ -41,6 +41,8 @@ ControlClient::~ControlClient(void) { #ifdef DEBUG cerr << __FILE__ << ": destructor." << endl; #endif // DEBUG + // TODO Temporal: espero que el receiver muera. + receiver.finish(true); } ControlClient::ControlClient(const string& host, const Connection::Port& port): @@ -65,8 +67,10 @@ void ControlClient::real_run(void) { } host = socket->localhost(); port = socket->localport(); - // TODO sacar a la mierda? + // TODO sacar signal_connected? connected(); + // TODO Temporal: el receiver empieza a escuchar. + receiver.run(); while (!stop) { HTTPResponse response; try { @@ -115,6 +119,11 @@ ControlClient::SignalErrorReceived& ControlClient::signal_error_received(void) { return error_received; } +// TODO - temporal +Receiver::SignalFrameReceived& ControlClient::signal_frame_received(void) { + return receiver.signal_frame_received(); +} + } // namespace Server } // namespace PlaQui diff --git a/Server/tests/client_test.cpp b/Server/tests/client_test.cpp index 0ab975b..c5fc75f 100644 --- a/Server/tests/client_test.cpp +++ b/Server/tests/client_test.cpp @@ -50,6 +50,11 @@ void on_ok_received(const string& body) { cout << " Body: " << body << endl; } +void on_frame_received(const string& frame) { + cout << " Frame recibido! :-D" << endl; + cout << frame << endl; +} + void on_error_received(unsigned code) { cout << " Respuesta recibida: Error nro " << code << "! :-(" << endl; } @@ -88,6 +93,7 @@ int main(int argc, char* argv[]) { client->signal_connected().connect(SigC::slot(on_connected)); client->signal_ok_received().connect(SigC::slot(on_ok_received)); client->signal_error_received().connect(SigC::slot(on_error_received)); + client->signal_frame_received().connect(SigC::slot(on_frame_received)); client->run(); char buf[BUFSIZ]; while (cin.getline(buf, BUFSIZ)) { -- 2.43.0