1 /***************************************************************************
2 * Copyright (C) 2006 by Gerd v. Egidy *
5 * This library is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Lesser General Public License version *
7 * 2.1 as published by the Free Software Foundation. *
9 * This library is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
19 #ifndef __LIBT2N_SERVER
20 #define __LIBT2N_SERVER
38 connection(int _timeout)
40 set_timeout(_timeout);
51 void set_timeout(int _timeout)
60 virtual void fill_buffer(void)=0;
62 bool get_packet(std::string& data, unsigned int& conn_id);
63 virtual void write(const std::string& data)=0;
69 enum log_level_values { none=0, error=1, debug=2 };
73 log_level_values log_level;
74 std::ostream *logstream;
77 std::map<unsigned int, connection*> connections;
82 set_default_timeout(30);
83 set_logging(NULL,none);
90 void set_default_timeout(int _default_timeout)
91 { default_timeout=_default_timeout; }
93 void set_logging(std::ostream *_logstream, log_level_values _log_level)
99 connection* get_connection(unsigned int conn_id);
101 virtual void fill_buffer(long long usec_timeout=-1)=0;
102 void check_timeout();
104 bool get_packet(std::string& data, unsigned int& conn_id);
106 void fill_connection_buffers(void);
109 void log(log_level_values level, const std::string& message)
110 { log(level,message.c_str()); }
111 void log(log_level_values level, const char* message);