blob: 9a801ecd0b48b8f875c5d2b9253108b37140017d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
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 <sys/select.h>
#include <string>
#include <deque>
#include <map>
#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<std::string> recvq;
fd_set clientset;
};
}
#endif // __INCLUDED_CORE_NETCONNECTION_H__
|