author | Tero Marttila <terom@fixme.fi> |
Sun, 02 Jun 2013 16:15:23 +0300 | |
changeset 448 | 34bdf0783874 |
parent 431 | c6d7272a164b |
permissions | -rw-r--r-- |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
1 |
#ifndef NETWORK_NODE_HH |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
2 |
#define NETWORK_NODE_HH |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
3 |
|
400
d64bf28c4340
more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents:
286
diff
changeset
|
4 |
/** |
d64bf28c4340
more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents:
286
diff
changeset
|
5 |
* @file |
d64bf28c4340
more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents:
286
diff
changeset
|
6 |
* |
d64bf28c4340
more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents:
286
diff
changeset
|
7 |
* Remote NetworkSessions |
d64bf28c4340
more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents:
286
diff
changeset
|
8 |
*/ |
d64bf28c4340
more documentation tweaking, all Network/ files now have a @file comment. Fix Platform.h -> Platform.hh, and Buffer.hh + Packet.cc
Tero Marttila <terom@fixme.fi>
parents:
286
diff
changeset
|
9 |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
10 |
// forward-declare |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
11 |
class NetworkNode; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
12 |
|
286 | 13 |
/** |
14 |
* Used to differentiate between different kinds of nodes in NetworkSession::build_node |
|
15 |
* |
|
16 |
* @see NetworkSession::build_node |
|
17 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
18 |
enum NetworkNodeType { |
286 | 19 |
NETWORK_NODE_SERVER_CLIENT, //<<< A server's client |
20 |
NETWORK_NODE_CLIENT_SERVER //<<< A client's server |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
21 |
}; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
22 |
|
186 | 23 |
#include "TCP.hh" |
24 |
#include "UDP.hh" |
|
25 |
#include "Session.hh" |
|
431
c6d7272a164b
rework Network send() code to use NetworkTarget/Node/Group::send classes, add a NetworkMessage class for sending NetworkObject messages, and fix a bug whereby the server's client TCP sockets weren't nonblocking.... I wonder how this has worked before?\!
Tero Marttila <terom@fixme.fi>
parents:
400
diff
changeset
|
26 |
#include "Target.hh" |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
27 |
|
286 | 28 |
/** |
29 |
* A NetworkNode represents a remote NetworkSession connected to our NetworkSession. |
|
30 |
* |
|
31 |
* A NetworkNode has a tcp connection, plus an udp socket to us (either NetworkSession's udp_srv or udp_client) |
|
431
c6d7272a164b
rework Network send() code to use NetworkTarget/Node/Group::send classes, add a NetworkMessage class for sending NetworkObject messages, and fix a bug whereby the server's client TCP sockets weren't nonblocking.... I wonder how this has worked before?\!
Tero Marttila <terom@fixme.fi>
parents:
400
diff
changeset
|
32 |
* |
c6d7272a164b
rework Network send() code to use NetworkTarget/Node/Group::send classes, add a NetworkMessage class for sending NetworkObject messages, and fix a bug whereby the server's client TCP sockets weren't nonblocking.... I wonder how this has worked before?\!
Tero Marttila <terom@fixme.fi>
parents:
400
diff
changeset
|
33 |
* NetworkNode implements the NetworkTarget interface, so you can use send() |
286 | 34 |
*/ |
431
c6d7272a164b
rework Network send() code to use NetworkTarget/Node/Group::send classes, add a NetworkMessage class for sending NetworkObject messages, and fix a bug whereby the server's client TCP sockets weren't nonblocking.... I wonder how this has worked before?\!
Tero Marttila <terom@fixme.fi>
parents:
400
diff
changeset
|
35 |
class NetworkNode : public NetworkTarget { |
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
36 |
private: |
286 | 37 |
/** |
38 |
* Our local NetworkSession |
|
39 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
40 |
NetworkSession &session; |
286 | 41 |
|
42 |
/** |
|
43 |
* The TCP connection |
|
44 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
45 |
NetworkTCPTransport *tcp; |
286 | 46 |
|
47 |
/** |
|
48 |
* Our NetworkSession's UDP socket that we should use to send UDP packets to this node |
|
49 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
50 |
NetworkUDP *udp; |
286 | 51 |
|
52 |
/** |
|
53 |
* This address that the node connected from using TCP, used to associate received UDP packets with this node |
|
54 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
55 |
const NetworkAddress address; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
56 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
57 |
CL_SlotContainer slots; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
58 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
59 |
public: |
286 | 60 |
/** |
61 |
* Construct a new NetworkNode from the given tcp/udp sockets and address |
|
62 |
* |
|
63 |
* @param session our NetworkSession |
|
64 |
* @param tcp this node's TCP socket |
|
65 |
* @param udp the UDP socket to use for outgoing packets |
|
66 |
* @param address the remote address |
|
67 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
68 |
NetworkNode (NetworkSession &session, NetworkTCPTransport *tcp, NetworkUDP *udp, const NetworkAddress &address); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
69 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
70 |
private: |
286 | 71 |
/** |
72 |
* Node should not be copied |
|
73 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
74 |
NetworkNode (const NetworkNode ©); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
75 |
~NetworkNode (void); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
76 |
NetworkNode& operator= (const NetworkNode ©); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
77 |
|
286 | 78 |
/** |
79 |
* Our TCP socket indicates disconnect, tell NetworkSession and trigger sig_disconnect |
|
80 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
81 |
void on_disconnect (void); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
82 |
|
286 | 83 |
/** |
84 |
* Our disconnect signal |
|
85 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
86 |
CL_Signal_v0 _sig_disconnected; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
87 |
|
431
c6d7272a164b
rework Network send() code to use NetworkTarget/Node/Group::send classes, add a NetworkMessage class for sending NetworkObject messages, and fix a bug whereby the server's client TCP sockets weren't nonblocking.... I wonder how this has worked before?\!
Tero Marttila <terom@fixme.fi>
parents:
400
diff
changeset
|
88 |
protected: |
286 | 89 |
/** |
431
c6d7272a164b
rework Network send() code to use NetworkTarget/Node/Group::send classes, add a NetworkMessage class for sending NetworkObject messages, and fix a bug whereby the server's client TCP sockets weren't nonblocking.... I wonder how this has worked before?\!
Tero Marttila <terom@fixme.fi>
parents:
400
diff
changeset
|
90 |
* Send the given packet to this node, used by NetworkTarget |
286 | 91 |
*/ |
431
c6d7272a164b
rework Network send() code to use NetworkTarget/Node/Group::send classes, add a NetworkMessage class for sending NetworkObject messages, and fix a bug whereby the server's client TCP sockets weren't nonblocking.... I wonder how this has worked before?\!
Tero Marttila <terom@fixme.fi>
parents:
400
diff
changeset
|
92 |
virtual void send_pkt (const NetworkPacketBuffer &pkt, bool reliable = true); |
286 | 93 |
|
431
c6d7272a164b
rework Network send() code to use NetworkTarget/Node/Group::send classes, add a NetworkMessage class for sending NetworkObject messages, and fix a bug whereby the server's client TCP sockets weren't nonblocking.... I wonder how this has worked before?\!
Tero Marttila <terom@fixme.fi>
parents:
400
diff
changeset
|
94 |
public: |
286 | 95 |
/** |
96 |
* Get this node's remote address (both TCP and UDP). |
|
97 |
* |
|
98 |
* @return NetworkAddress the remote address |
|
99 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
100 |
const NetworkAddress& getRemoteAddress (void); |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
101 |
|
286 | 102 |
/** |
103 |
* This node's TCP connection was lost, and the node has been removed from the NetworkSession's nodes list. |
|
104 |
* |
|
105 |
* Once this completes, the node will be destructed |
|
106 |
*/ |
|
185
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
107 |
CL_Signal_v0& sig_disconnected (void) { return _sig_disconnected; } |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
108 |
}; |
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
109 |
|
25becd2cb026
that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff
changeset
|
110 |
#endif /* NETWORK_NODE_HH */ |