~lucadestudios/lucadestudios/trunk

« back to all changes in this revision

Viewing changes to engine/src/shared/network/src/shared/network/node.h

  • Committer: Sean Hodges
  • Date: 2009-04-27 11:13:39 UTC
  • mfrom: (62.1.18 trunk)
  • Revision ID: seanhodges@bluebottle.com-20090427111339-d0ay5y47wxu3qlj1
Merged with upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef NODE_H_INCLUDED
 
2
#define NODE_H_INCLUDED
 
3
 
 
4
#include <vector>
 
5
#include <boost/thread.hpp>
 
6
 
 
7
#include "ip_addressv4.h"
 
8
#include "node_process.h"
 
9
 
 
10
namespace lucade {
 
11
namespace network {
 
12
 
 
13
class connection;
 
14
typedef boost::shared_ptr<connection> connection_ptr;
 
15
 
 
16
class packet;
 
17
 
 
18
class node {
 
19
public:
 
20
    node(node_process_ptr process);
 
21
 
 
22
    bool start();
 
23
    void stop();
 
24
 
 
25
    connection_ptr spawn_connection(ip_addressv4 toWhere=ip_addressv4());
 
26
    int get_connection_count() const;
 
27
    connection_ptr get_connection(int id) const;
 
28
private:
 
29
    void queue_packet(boost::shared_ptr<packet> packetToSend); ///!< Queues a packet to send via the node_process
 
30
    node_process_ptr _process;
 
31
    boost::shared_ptr<boost::thread> _process_thread;
 
32
 
 
33
    std::vector<connection_ptr> _connections;
 
34
 
 
35
    virtual void on_pre_start() = 0;
 
36
    virtual void on_post_start() = 0;
 
37
    virtual void on_pre_stop() = 0;
 
38
    virtual void on_post_stop() = 0;
 
39
 
 
40
friend class connection;
 
41
};
 
42
 
 
43
typedef boost::shared_ptr<node> node_ptr;
 
44
}
 
45
}
 
46
 
 
47
#endif // NODE_H_INCLUDED