duncan
Mom and Dad were wrong!
/home/malcolm/tmp/duncan/prototype/0/network/connection.h
00001 #ifndef NETWORK_CONNECTION_H_
00002 #define NETWORK_CONNECTION_H_
00003 
00004 #include <enet/enet.h>
00005 #include <stdexcept>
00006 #include <string>
00007 #include <vector>
00008 #include "network.h"
00009 #include "packetlistener.h"
00010 
00011 namespace net {
00012 
00025 class Connection {
00026         private:
00027                 ENetHost* host_;
00028                 PacketListener* listener_;
00029                 std::vector<ENetPeer*> peers_;
00030                 index_t ind_;
00031                 bool connected_;
00032                 static int enetinit;
00033                 void init();
00034         public:
00035                 Connection(const std::string& address, PacketListener* lis = 0, port_t port = kPort);
00036                 Connection(port_t port = kPort);
00037                 ~Connection();
00038                 void send(const void* buf, size_t size, index_t peer = 0, bool reliable = kReliable);
00039                 void set_listener(PacketListener*);
00040                 bool connected();
00041                 void receive();
00042 
00043                 unsigned int bytes_sent();
00044                 unsigned int bytes_received();
00045 };
00046 
00047 } // namespace
00048 
00049 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations