/* net/netconnection.cc This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_CORE_NETCONNECTION_H__ #define __INCLUDED_CORE_NETCONNECTION_H__ #include #include #include #include #include "net/tcpconnection.h" namespace core { /// a client to server connection class NetConnection : public net::TCPConnection { public: NetConnection(); virtual ~NetConnection(); /// connect to a remote host virtual void connect(std::string const &to_host, int to_port); /// disconnect from a remote host virtual void disconnect(); /// process pending incoming messages void frame(float seconds); protected: /// receive incoming data and store messages void receive(); /// return true if there are incoming messages bool has_messages() const; /// retreive an incoming message void retreive(std::string & message); /// parse an incoming message void parse_incoming_message(const std::string & message); private: std::string messageblock; std::deque recvq; fd_set clientset; }; } #endif // __INCLUDED_CORE_NETCONNECTION_H__