From 1e50540e75965e61fad19bc0a062a33b416fdc25 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 14 Sep 2023 17:05:44 +0200 Subject: [PATCH] CoapClient - Added new constructor `this(string host, ushort port)` -This constructor provided name resolution on the host part. Client (unit tests) - Updated unit test to use the new `CoapClient` name-resolution-based constructor --- source/doap/client/client.d | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/source/doap/client/client.d b/source/doap/client/client.d index 18d3b03..8e8bb4c 100644 --- a/source/doap/client/client.d +++ b/source/doap/client/client.d @@ -60,6 +60,22 @@ public class CoapClient init(); } + /** + * Constructs a new CoAP client to the + * provided endpoint address and port. + * + * This constructor provided name + * resolution on the host part. + * + * Params: + * host = the CoAP host + * port = the CoAP port + */ + this(string host, ushort port) + { + this(new InternetAddress(host, port)); + } + /** * Sets up a new datagram socket, * sets the running status to `true` @@ -241,8 +257,7 @@ version(unittest) */ unittest { - Address addr = new InternetAddress("coap.me", 5683); - CoapClient client = new CoapClient(addr); + CoapClient client = new CoapClient("coap.me", 5683); CoapRequestFuture future = client.newRequestBuilder().payload(cast(ubyte[])"Hello this is Tristan!")