{ connection_id=_connection_id; }
protected:
- server_connection(int _timeout)
- : connection()
- {
- set_timeout(_timeout);
- reset_timeout();
- connection_id=0;
- my_server=0;
- }
-
server *my_server;
+ server_connection(int _timeout);
+
+ std::ostream* get_logstream(log_level_values level);
+
public:
- /// check if timeout is expired, close connection if so
void check_timeout();
-
- /// reset the timeout, e.g. if something is received
void reset_timeout();
-
void set_timeout(int _timeout)
{ timeout=_timeout; }
protected:
std::map<unsigned int, server_connection*> connections;
- server()
- {
- set_default_timeout(30);
- set_logging(NULL,none);
- next_id=1;
- }
+ server();
virtual bool fill_connection_buffers(void)=0;
int get_default_timeout(void)
{ return default_timeout; }
- /// activate logging to the given stream. everything above the given level is logged.
- void set_logging(std::ostream *_logstream, log_level_values _log_level)
- {
- log_level=_log_level;
- logstream=_logstream;
- }
+ void set_logging(std::ostream *_logstream, log_level_values _log_level);
server_connection* get_connection(unsigned int conn_id);
bool get_packet(std::string& data)
{ unsigned int x; return get_packet(data,x); }
- /** @brief get a complete data packet from any client. The packet is removed from the
- connection buffer.
- @param[out] data the data package
- @param[out] conn_id the connection id we got this packet from
- @retval true if packet found
- */
bool get_packet(std::string& data, unsigned int& conn_id);
- /// write a message to the log if logging is enabled
- void log(log_level_values level, const std::string& message)
- { log(level,message.c_str()); }
- /// write a message to the log if logging is enabled
- void log(log_level_values level, const char* message);
+ std::ostream* get_logstream(log_level_values level);
};
}