/*! \file connection.h
This is the generic Connection class definition.
\author Jon A. Lambert
\date 05/02/2003
\version 0.30
*/
#ifndef CONNECTION_H
#define CONNECTION_H
/*!
The Connection class contains the information required to maintain a
socket connection with a client.
\todo
The bottomless buffer may not be a grand idea as it can be a DOS attack.
So perhaps we assign a quota and/or input rate fetched from the driver's
User record.
*/
class Socket;
class Server;
class Connection {
public:
Connection(SOCKET sock, Server* server);
virtual ~Connection();
Connection(const Connection& r_conn);
bool operator==(const Connection& r_conn) const;
virtual void HandleInput();
virtual void HandleOutput();
virtual bool CanBeDisconnected();
virtual bool HasOutput();
virtual void Disconnect();
virtual void SendMsg(const string& r_msg);
virtual string* ReadMsg();
virtual SOCKET GetSocket() const;
protected:
Connection& operator=(const Connection& r_conn);
Server * mServer; //!< Server serving this connection.
Socket * mSock; //!< Network Socket stream.
bool mDisconnectable; //!< Indicates connection is to be disconnected.
list<string> mInBuffer; //!< Buffered input waiting to be processed.
list<string> mOutBuffer; //!< Buffered output waiting to be sent.
string mPendingInput; //!< Partially processed or formed input.
};
#endif // CONNECTION_H