]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Server/include/plaqui/server/tcpserver.h
- Se sobreescribe el método Connection::finish() para que cierre el socket.
[z.facultad/75.42/plaqui.git] / Server / include / plaqui / server / tcpserver.h
index b37984428858668a09da3b2a4a7c0486496d0280..1cd344f4da3599eea86ddade2da09cfc7df9783c 100644 (file)
 #ifndef PLAQUI_TCPSERVER_H
 #define PLAQUI_TCPSERVER_H
 
 #ifndef PLAQUI_TCPSERVER_H
 #define PLAQUI_TCPSERVER_H
 
-#include "plaqui/server/controlserver.h"
-#include "plaqui/server/transmitter.h"
+#include "plaqui/server/runnable.h"
+#include "plaqui/server/connection.h"
 #include <socket++/sockinet.h>
 #include <socket++/sockinet.h>
-#include <string>
 #include <list>
 #include <list>
+#include <vector>
 
 namespace PlaQui {
 
 
 namespace PlaQui {
 
@@ -44,12 +44,32 @@ namespace Server {
         */
        class TCPServer: public Runnable {
 
         */
        class TCPServer: public Runnable {
 
+               // Constantes.
+
+               private:
+
+                       /// Cantidad máxima de conexiones pendientes.
+                       static const unsigned MAX_PENDING_CONNECTIONS = 10;
+
                // Tipos.
 
                private:
 
                        /// Lista de conexiones de control.
                // Tipos.
 
                private:
 
                        /// Lista de conexiones de control.
-                       typedef std::list<Connnection*> ConnectionList;
+                       typedef std::list<Connection*> ConnectionList;
+
+               public:
+
+                       /// Información sobre una conexión de contro.
+                       struct ConnectionInfo {
+                               /// Host.
+                               std::string host;
+                               /// Port.
+                               unsigned port;
+                       };
+
+                       /// Lista de información de conexiones de control.
+                       typedef std::vector<ConnectionInfo> ConnectionInfoList;
 
                // Atributos.
 
 
                // Atributos.
 
@@ -58,6 +78,9 @@ namespace Server {
                        /// Socket para escuchar conexiones.
                        sockinetbuf socket;
 
                        /// Socket para escuchar conexiones.
                        sockinetbuf socket;
 
+                       /// Mutex para las conexiones.
+                       Glib::Mutex connections_mutex;
+
                        /// Conexiones de control.
                        ConnectionList connections;
 
                        /// Conexiones de control.
                        ConnectionList connections;
 
@@ -86,7 +109,7 @@ namespace Server {
                        /**
                         * Destructor.
                         */
                        /**
                         * Destructor.
                         */
-                       virtual ~TCPServer(void) {}
+                       virtual ~TCPServer(void);
 
                        /**
                         * Constructor.
 
                        /**
                         * Constructor.
@@ -102,6 +125,11 @@ namespace Server {
                         */
                        void on_connection_finished(Connection* connection);
 
                         */
                        void on_connection_finished(Connection* connection);
 
+                       /**
+                        * Obtiene una lista conexiones de control abiertas.
+                        */
+                       ConnectionInfoList get_connected(void);
+
        };
 
 }
        };
 
 }