--- a/src/Network/Node.hh Mon Jan 26 19:52:52 2009 +0200
+++ b/src/Network/Node.hh Mon Jan 26 23:03:47 2009 +0200
@@ -23,13 +23,16 @@
#include "TCP.hh"
#include "UDP.hh"
#include "Session.hh"
+#include "Target.hh"
/**
* A NetworkNode represents a remote NetworkSession connected to our NetworkSession.
*
* A NetworkNode has a tcp connection, plus an udp socket to us (either NetworkSession's udp_srv or udp_client)
+ *
+ * NetworkNode implements the NetworkTarget interface, so you can use send()
*/
-class NetworkNode {
+class NetworkNode : public NetworkTarget {
private:
/**
* Our local NetworkSession
@@ -82,41 +85,13 @@
*/
CL_Signal_v0 _sig_disconnected;
- public:
- /**
- * Write to appropriate NetworkSession header to the given packet. Can be used to prepare packets for use with
- * send_raw. The size of the header is equal to NETWORK_SESSION_HEADER_SIZE
- *
- * @param pkt the packet to write the header to
- * @param channel_id the NetworkChannelID to use
- *
- * @see send_raw
- * @see NETWORK_SESSION_HEADER_SIZE
- */
- void write_packet_header (NetworkPacketOutput &pkt, NetworkChannelID channel_id);
-
+ protected:
/**
- * Send a raw packet prepared using write_packet_header. This does not need to copy the packet data around.
- *
- * @param pkt the NetworkPacket prepared using write_packet_header
- * @param reliable Whether to use TCP or UDP
- *
- * @see write_packet_header
+ * Send the given packet to this node, used by NetworkTarget
*/
- void send_raw (const NetworkPacketBuffer &pkt, bool reliable = true);
-
- /**
- * Send the given packet to this node on the given channel.
- *
- * Note that this constructs a new *NetworkPacket* containing our header and the given packet, so there
- * given packet must be small enough to fit.
- *
- * @param channel_id the NetworkChannelID to use
- * @param pkt the NetworkPacket to send on the given channel
- * @param reliable Whether to use TCP or UDP
- */
- void send (NetworkChannelID channel_id, const NetworkPacketBuffer &pkt, bool reliable = true);
+ virtual void send_pkt (const NetworkPacketBuffer &pkt, bool reliable = true);
+ public:
/**
* Get this node's remote address (both TCP and UDP).
*