]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Server/src/server.cpp
Ya se mandan seniales cuando se reciben comandos.
[z.facultad/75.42/plaqui.git] / Server / src / server.cpp
index 81285cbe61fdabd24338cc250f578548999c1897..a05285a60b8c8a5140b1a7a569df17df355333bd 100644 (file)
 //
 
 #include "plaqui/server/server.h"
 //
 
 #include "plaqui/server/server.h"
+#include "plaqui/server/connection.h"
+#include "plaqui/server/controlserver.h"
+#include <sigc++/class_slot.h>
 #ifdef DEBUG
 #ifdef DEBUG
+#      include "plaqui/server/string.h"
 #      include <iostream>
 #endif // DEBUG
 
 #      include <iostream>
 #endif // DEBUG
 
-PlaQui::Server::Server::~Server(void) {
+using namespace std;
+
+namespace PlaQui {
+
+namespace Server {
+
+Server::~Server(void) {
 #ifdef DEBUG
 #ifdef DEBUG
-       std::cerr << __FILE__ <<  ": destructor." << std::endl;
+       cerr << __FILE__ <<  ": destructor." << endl;
 #endif // DEBUG
 }
 
 #endif // DEBUG
 }
 
-PlaQui::Server::Server::Server(int port):
-               PlaQui::Server::Server::TCPServer(port) {
+Server::Server(int port):
+               TCPServer(port) {
 #ifdef DEBUG
 #ifdef DEBUG
-       std::cerr << __FILE__ <<  ": port = " << port << std::endl;
+       cerr << __FILE__ <<  ": port = " << port << endl;
 #endif // DEBUG
 }
 
 /// \todo Implementar.
 #endif // DEBUG
 }
 
 /// \todo Implementar.
-bool PlaQui::Server::Server::start_transmission(std::string host, int port) {
+bool Server::start_transmission(string host, int port) {
 #ifdef DEBUG
 #ifdef DEBUG
-       std::cerr << __FILE__ <<  ": start_transmission(host = " << host
-               << " | port = " << port << ")" << std::endl;
+       cerr << __FILE__ <<  ": start_transmission(host = " << host
+               << " | port = " << port << ")" << endl;
 #endif // DEBUG
        // TODO
        return false;
 }
 #endif // DEBUG
        // TODO
        return false;
 }
+                       
+Connection* Server::new_connection(
+               const sockbuf::sockdesc& sd) {
+#ifdef DEBUG
+       cerr << __FILE__ <<  ": new_connection(sd = " << sd.sock << ")"
+               << endl;
+#endif // DEBUG
+       ControlServer* connection = new ControlServer(sd);
+       // TODO verificar si el new se hace bien? no creo.
+       connection->signal_command_received().connect(
+                       SigC::slot_class(*this, &Server::on_control_command_received));
+       // TODO: 
+       return connection;
+}
 
 /// \todo Implementar.
 
 /// \todo Implementar.
-bool PlaQui::Server::Server::stop_transmission(std::string host, int port) {
+bool Server::stop_transmission(string host, int port) {
 #ifdef DEBUG
 #ifdef DEBUG
-       std::cerr << __FILE__ <<  ": stop_transmission(host = " << host
-               << " | port = " << port << ")" << std::endl;
+       cerr << __FILE__ <<  ": stop_transmission(host = " << host
+               << " | port = " << port << ")" << endl;
 #endif // DEBUG
        // TODO
        return false;
 }
 
 /// \todo Implementar.
 #endif // DEBUG
        // TODO
        return false;
 }
 
 /// \todo Implementar.
-void PlaQui::Server::Server::on_control_command_received(void* command) {
+void Server::on_control_command_received(const Command& command) {
 #ifdef DEBUG
 #ifdef DEBUG
-       std::cerr << __FILE__ <<  ": on_control_command_received(command = "
-               << command << ")" << std::endl;
+       cerr << __FILE__ <<  ": on_control_command_received(target = "
+               << command.get_target() << ", command = " << command.get_command()
+               << ", args = [" << String::join(command.get_args(), ", ") << "])"
+               << endl;
 #endif // DEBUG
 }
 
 #endif // DEBUG
 }
 
+} // namespace Server
+
+} // namespace PlaQui
+