]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Ya se mandan seniales cuando se reciben comandos.
authorLeandro Lucarella <llucax@gmail.com>
Sun, 9 Nov 2003 23:59:33 +0000 (23:59 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Sun, 9 Nov 2003 23:59:33 +0000 (23:59 +0000)
Server/include/plaqui/server/command.h
Server/include/plaqui/server/controlserver.h
Server/include/plaqui/server/receiver.h
Server/include/plaqui/server/server.h
Server/src/Makefile
Server/src/command.cpp
Server/src/controlserver.cpp
Server/src/receiver.cpp
Server/src/server.cpp

index 019cad2e20c6ae5ae316a421ae0a76f9ee7e53bb..fafa951771fad114699cb73b4f0fce2dfe59a92c 100644 (file)
@@ -91,7 +91,7 @@ namespace Server {
                        /**
                         * Obtiene el destino.
                         */
-                       const std::string& get_target(void);
+                       const std::string& get_target(void) const;
 
                        /**
                         * Establece el comando.
@@ -101,7 +101,7 @@ namespace Server {
                        /**
                         * Obtiene el comand.
                         */
-                       const std::string& get_command(void);
+                       const std::string& get_command(void) const;
 
                        /**
                         * Establece los argumentos.
@@ -111,7 +111,7 @@ namespace Server {
                        /**
                         * Obtiene los argumentos.
                         */
-                       const Arguments& get_args(void);
+                       const Arguments& get_args(void) const;
 
                        /**
                         * Agrega un argumentos.
index f269e4b92427e5b87de7a5fa02675491b3f9ac19..5b6eb23e553ec43c73604dc569493df289ba6024 100644 (file)
@@ -28,7 +28,8 @@
 #ifndef PLAQUI_CONTROLSERVER_H
 #define PLAQUI_CONTROLSERVER_H
 
-#include "plaqui/server/serverconnection.h"
+#include "plaqui/server/connection.h"
+#include "plaqui/server/command.h"
 #include <socket++/sockinet.h>
 
 namespace PlaQui {
@@ -36,7 +37,24 @@ namespace PlaQui {
 namespace Server {
 
        /// Conexión para recibir comandos de control para una planta.
-       class ControlServer: public ServerConnection {
+       class ControlServer: public Connection {
+
+               // Tipos.
+
+               public:
+
+                       /// Tipo de señal para indicar que se recibió un comando.
+                       typedef SigC::Signal1<void, const Command&> SignalCommandReceived;
+
+               // Atributos.
+
+               private:
+
+                       /// Señal para indicar que se recibió un comando.
+                       SignalCommandReceived command_received;
+
+
+               // Métodos.
 
                protected:
 
@@ -59,6 +77,11 @@ namespace Server {
                         */
                        ControlServer(const sockbuf::sockdesc& sd);
 
+                       /**
+                        * Obtiene la señal que avisa cuando se recibió un comando.
+                        */
+                       SignalCommandReceived& signal_command_received(void);
+
        };
 
 }
index de481f6e77a23548ffc15b31b31cf21374af9b73..5b8c6351059ae0eb602a93fbe2c96475e0d094c8 100644 (file)
@@ -28,7 +28,7 @@
 #ifndef PLAQUI_RECEIVER_H
 #define PLAQUI_RECEIVER_H
 
-#include "plaqui/server/serverconnection.h"
+#include "plaqui/server/connection.h"
 #include <socket++/sockinet.h>
 #include <string>
 
@@ -37,7 +37,7 @@ namespace PlaQui {
 namespace Server {
 
        /// Conexión para recibir el estado de una planta.
-       class Receiver: public ServerConnection {
+       class Receiver: public Connection {
 
                private:
 
index 3776cc72e9462dd1e6a2fd569b9b247efa68d016..e66be38c1ee985eaeec8211b3d50c03a2df1ed82 100644 (file)
@@ -31,6 +31,7 @@
 #include "plaqui/server/tcpserver.h"
 #include "plaqui/server/controlserver.h"
 #include "plaqui/server/transmitter.h"
+#include "plaqui/server/command.h"
 #include <socket++/sockinet.h>
 #include <string>
 #include <list>
@@ -124,7 +125,7 @@ namespace Server {
                         *
                         * \todo Hacer un tipo Command abstracto o algo así.
                         */
-                       void on_control_command_received(void* command);
+                       void on_control_command_received(const Command& command);
 
        };
 
index 683723f899a16f627cbac9d2c09c7d9be4d322c1..0403d202f29b01d97b47805830f1c4a326419260 100644 (file)
@@ -74,9 +74,9 @@ connection_h=$(runnable_h) $(INCLUDE_DIR)/connection.h
 objects+=connection.o
 connection.o: $(connection_h) connection.cpp
 
-serverconnection_h=$(connection_h) $(INCLUDE_DIR)/serverconnection.h
-objects+=serverconnection.o
-serverconnection.o: $(serverconnection_h) serverconnection.cpp
+#serverconnection_h=$(connection_h) $(INCLUDE_DIR)/serverconnection.h
+#objects+=serverconnection.o
+#serverconnection.o: $(serverconnection_h) serverconnection.cpp
 
 controlclient_h=$(connection_h) $(command_h) $(INCLUDE_DIR)/controlclient.h
 objects+=controlclient.o
index 91d82ce4491cd74457c24969a93346c7a9b8dd19..5448ea6be47c9db393818916d48dfb82d04c8293 100644 (file)
@@ -64,7 +64,7 @@ void Command::set_target(const std::string& _target) {
        build();
 }
 
-const std::string& Command::get_target(void) {
+const std::string& Command::get_target(void) const {
        return target;
 }
 
@@ -73,7 +73,7 @@ void Command::set_command(const std::string& _command) {
        build();
 }
 
-const std::string& Command::get_command(void) {
+const std::string& Command::get_command(void) const {
        return command;
 }
 
@@ -82,7 +82,7 @@ void Command::set_args(const Command::Arguments& _args) {
        build();
 }
 
-const Command::Arguments& Command::get_args(void) {
+const Command::Arguments& Command::get_args(void) const {
        return args;
 }
 
index 7a4cedc0ba2944eaa9f6a1b86020f887d7e1db7a..c5e163fe44e8d71044c563ed876a2e6071ce94b9 100644 (file)
@@ -47,7 +47,7 @@ ControlServer::~ControlServer(void) {
 }
 
 ControlServer::ControlServer(const sockbuf::sockdesc& sd):
-               ServerConnection(sd) {
+               Connection(sd) {
 #ifdef DEBUG
        cerr << __FILE__ << ": sd = " << sd.sock << endl;
 #endif // DEBUG
@@ -110,18 +110,13 @@ void ControlServer::real_run(void) {
                        }
                }
 */
-               // TODO: Manda el comando.
-               // Command command = parse_command(request.uri);
-               //signal_command_received().emit(command);
+               // Manda el comando.
+               command_received.emit(command);
 #ifdef DEBUG
                cerr << "Comando: target = " << command.get_target()
                        << " | command = " << command.get_command()
                        << " | args = [" << String::join(command.get_args(), ", ") << "]"
                        << endl;
-               //for (HTTPRequest::const_iterator i = request.begin();
-               //              i != request.end(); i++) {
-               //      cerr << "   " << i->first << ": " << i->second << endl;
-               //}
 #endif // DEBUG
                // FIXME - hacer respuesta XML.
                // La respuesta hay que mandarla asincrónicamente porque no puedo
@@ -182,6 +177,10 @@ Accept-Ranges: bytes
        }
 }
 
+ControlServer::SignalCommandReceived& ControlServer::signal_command_received(void) {
+       return command_received;
+}
+
 } // namespace Server
 
 } // namespace PlaQui
index 2a8e9bf1c7f62ec2e52308e2dd8a67e1a54829b5..c381c7d6d104683c32e745d43bde76280099281e 100644 (file)
@@ -42,8 +42,7 @@ Receiver::~Receiver(void) {
 #endif // DEBUG
 }
 
-Receiver::Receiver(int port, string host):
-               ServerConnection(sockbuf::sock_dgram) {
+Receiver::Receiver(int port, string host): Connection(sockbuf::sock_dgram) {
 #ifdef DEBUG
        cerr << __FILE__ << ": port = " << port
                << " | host = " << host << endl;
index 9d123f18923ec30d50f0a5cbfb3406bb97348b71..a05285a60b8c8a5140b1a7a569df17df355333bd 100644 (file)
@@ -30,6 +30,7 @@
 #include "plaqui/server/controlserver.h"
 #include <sigc++/class_slot.h>
 #ifdef DEBUG
+#      include "plaqui/server/string.h"
 #      include <iostream>
 #endif // DEBUG
 
@@ -87,10 +88,12 @@ bool Server::stop_transmission(string host, int port) {
 }
 
 /// \todo Implementar.
-void Server::on_control_command_received(void* command) {
+void Server::on_control_command_received(const Command& command) {
 #ifdef DEBUG
-       cerr << __FILE__ <<  ": on_control_command_received(command = "
-               << command << ")" << endl;
+       cerr << __FILE__ <<  ": on_control_command_received(target = "
+               << command.get_target() << ", command = " << command.get_command()
+               << ", args = [" << String::join(command.get_args(), ", ") << "])"
+               << endl;
 #endif // DEBUG
 }