X-Git-Url: http://developer.intra2net.com/git/?p=libt2n;a=blobdiff_plain;f=src%2Fserver.cpp;fp=src%2Fserver.cpp;h=3424cd832c56fe892e6f71419c3a87d7eb31ec02;hp=c8255eee677084d39c1571c813d5734e401efa05;hb=aa499d2034964a4c125794b7e8ea768cb7471411;hpb=04e6b2712bf0fdfdb6a74cf6d26f02e6a8d37ae2 diff --git a/src/server.cpp b/src/server.cpp index c8255ee..3424cd8 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -17,6 +17,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ +#include + #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 @@ -62,8 +71,11 @@ server::~server() int server::add_connection(connection* newconn) { - connections[next_id]=newconn; - return next_id++; + unsigned int cid=next_id++; + newconn->set_id(cid); + newconn->set_server(this); + connections[cid]=newconn; + return cid; } /** @@ -89,14 +101,6 @@ void server::check_timeout() i->second->check_timeout(); } -void server::fill_connection_buffers(void) -{ - std::map::iterator ie=connections.end(); - for(std::map::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