/**
* Obtiene el destino.
*/
- const std::string& get_target(void);
+ const std::string& get_target(void) const;
/**
* Establece el comando.
/**
* Obtiene el comand.
*/
- const std::string& get_command(void);
+ const std::string& get_command(void) const;
/**
* Establece los argumentos.
/**
* Obtiene los argumentos.
*/
- const Arguments& get_args(void);
+ const Arguments& get_args(void) const;
/**
* Agrega un argumentos.
#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 {
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:
*/
ControlServer(const sockbuf::sockdesc& sd);
+ /**
+ * Obtiene la señal que avisa cuando se recibió un comando.
+ */
+ SignalCommandReceived& signal_command_received(void);
+
};
}
#ifndef PLAQUI_RECEIVER_H
#define PLAQUI_RECEIVER_H
-#include "plaqui/server/serverconnection.h"
+#include "plaqui/server/connection.h"
#include <socket++/sockinet.h>
#include <string>
namespace Server {
/// Conexión para recibir el estado de una planta.
- class Receiver: public ServerConnection {
+ class Receiver: public Connection {
private:
#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>
*
* \todo Hacer un tipo Command abstracto o algo así.
*/
- void on_control_command_received(void* command);
+ void on_control_command_received(const Command& command);
};
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
build();
}
-const std::string& Command::get_target(void) {
+const std::string& Command::get_target(void) const {
return target;
}
build();
}
-const std::string& Command::get_command(void) {
+const std::string& Command::get_command(void) const {
return command;
}
build();
}
-const Command::Arguments& Command::get_args(void) {
+const Command::Arguments& Command::get_args(void) const {
return args;
}
}
ControlServer::ControlServer(const sockbuf::sockdesc& sd):
- ServerConnection(sd) {
+ Connection(sd) {
#ifdef DEBUG
cerr << __FILE__ << ": sd = " << sd.sock << endl;
#endif // DEBUG
}
}
*/
- // 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
}
}
+ControlServer::SignalCommandReceived& ControlServer::signal_command_received(void) {
+ return command_received;
+}
+
} // namespace Server
} // namespace PlaQui
#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;
#include "plaqui/server/controlserver.h"
#include <sigc++/class_slot.h>
#ifdef DEBUG
+# include "plaqui/server/string.h"
# include <iostream>
#endif // DEBUG
}
/// \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
}