libt2n: (gerd) small improvements, resolve doxygen conflicts
[libt2n] / src / server.cpp
index a319cf4..3424cd8 100644 (file)
@@ -17,6 +17,8 @@
  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  ***************************************************************************/
 
+#include <sstream>
+
 #include "server.hxx"
 
 namespace libt2n
@@ -33,6 +35,13 @@ void connection::reset_timeout()
     last_action_time=time(NULL);
 }
 
+std::string connection::get_id_string()
+{
+    std::ostringstream os;
+    os << get_id();
+    return os.str();
+}
+
 bool connection::get_packet(std::string& data, unsigned int& conn_id)
 {
     // max packet size is unsigned int
@@ -60,6 +69,22 @@ server::~server()
         delete i->second;
 }
 
+int server::add_connection(connection* newconn)
+{
+    unsigned int cid=next_id++;
+    newconn->set_id(cid);
+    newconn->set_server(this);
+    connections[cid]=newconn;
+    return cid;
+}
+
+/**
+    Gets a connection by id
+    
+    \param conn_id Connection ID
+    
+    \retval Pointer to connection object
+*/
 connection* server::get_connection(unsigned int conn_id)
 {
     std::map<unsigned int, connection*>::iterator p=connections.find(conn_id);
@@ -76,14 +101,6 @@ void server::check_timeout()
         i->second->check_timeout();
 }
 
-void server::fill_connection_buffers(void)
-{
-    std::map<unsigned int, connection*>::iterator ie=connections.end();
-    for(std::map<unsigned int, connection*>::iterator i=connections.begin(); i != ie; i++)
-        if (!i->second->is_closed())
-            i->second->fill_buffer();
-}
-
 bool server::get_packet(std::string& data, unsigned int& conn_id)
 {
     // todo: this is somehow unfair: the first connections in the map get checked more