}
server::server()
+ : callbacks(__events_end)
{
set_default_timeout(30);
set_logging(NULL,none);
delete i->second;
}
+/** @brief add a callback
+
+ @param event event the function will be called at
+ @param func functor (see boost function) that will be called
+*/
+void server::add_callback(callback_event_type event, const boost::function<void (server_connection*)>& func)
+{
+ callbacks[event].push_back(func);
+}
+
+void server::do_callbacks(callback_event_type event, server_connection* conn)
+{
+ std::list<boost::function<void (server_connection*)> >::iterator i,ie=callbacks[event].end();
+ for (i=callbacks[event].begin(); i != ie; i++)
+ (*i)(conn);
+}
+
int server::add_connection(server_connection* newconn)
{
unsigned int cid=next_id++;
LOGSTREAM(debug,"new connection accepted, id: " << cid);
+ do_callbacks(new_connection,newconn);
+
return cid;
}