Change Transport connect to use the new ConnectionInfo object.
diff --git a/ndn-cpp/transport/udp-transport.hpp b/ndn-cpp/transport/udp-transport.hpp
index 76c3f36..b720337 100644
--- a/ndn-cpp/transport/udp-transport.hpp
+++ b/ndn-cpp/transport/udp-transport.hpp
@@ -6,6 +6,7 @@
#ifndef NDN_UDPTRANSPORT_HPP
#define NDN_UDPTRANSPORT_HPP
+#include <string>
#include "../c/transport/udp-transport.h"
#include "../c/encoding/binary-xml-element-reader.h"
#include "transport.hpp"
@@ -14,18 +15,53 @@
class UdpTransport : public Transport {
public:
+ /**
+ * A UdpTransport::ConnectionInfo extends Transport::ConnectionInfo to hold the host and port info for the UDP connection.
+ */
+ class ConnectionInfo : public Transport::ConnectionInfo {
+ public:
+ /**
+ * Create a ConnectionInfo with the given host and port.
+ * @param host The host for the connection.
+ * @param port The port number for the connection.
+ */
+ ConnectionInfo(const char *host, unsigned short port)
+ : host_(host), port_(port)
+ {
+ }
+
+ /**
+ * Get the host given to the constructor.
+ * @return A string reference for the host.
+ */
+ const std::string &getHost() const { return host_; }
+
+ /**
+ * Get the port given to the constructor.
+ * @return The port number.
+ */
+ unsigned short getPort() const { return port_; }
+
+ virtual ~ConnectionInfo();
+
+ private:
+ std::string host_;
+ unsigned short port_;
+ };
+
UdpTransport()
- : node_(0), isConnected_(false)
+ : elementListener_(0), isConnected_(false)
{
ndn_UdpTransport_init(&transport_);
elementReader_.partialData.array = 0;
}
/**
- * Connect to the host specified in node.
- * @param node Not a shared_ptr because we assume that it will remain valid during the life of this Transport object.
+ * Connect according to the info in ConnectionInfo, and processEvents() will use elementListener.
+ * @param connectionInfo A reference to a TcpTransport::ConnectionInfo.
+ * @param elementListener Not a shared_ptr because we assume that it will remain valid during the life of this object.
*/
- virtual void connect(Node &node);
+ virtual void connect(const Transport::ConnectionInfo &connectionInfo, ElementListener &elementListener);
/**
* Set data to the host
@@ -35,7 +71,7 @@
virtual void send(const unsigned char *data, unsigned int dataLength);
/**
- * Process any data to receive. For each element received, call node.onReceivedElement.
+ * Process any data to receive. For each element received, call elementListener.onReceivedElement.
* This is non-blocking and will return immediately if there is no data to receive.
* You should normally not call this directly since it is called by Face.processEvents.
* @throw This may throw an exception for reading data or in the callback for processing the data. If you
@@ -55,7 +91,7 @@
private:
struct ndn_UdpTransport transport_;
bool isConnected_;
- Node *node_;
+ ElementListener *elementListener_;
// TODO: This belongs in the socket listener.
ndn_BinaryXmlElementReader elementReader_;
};