From d6eefb3a9b582de6ce2d3b04984afe9d30d5fee6 Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Mon, 25 Sep 2023 19:43:23 +0200 Subject: [PATCH] CoapClient - Implemented `newMid()` to provide a unique new mid --- source/doap/client/client.d | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/source/doap/client/client.d b/source/doap/client/client.d index c016378..d94f26a 100644 --- a/source/doap/client/client.d +++ b/source/doap/client/client.d @@ -74,6 +74,22 @@ public class CoapClient init(); } + package ulong newMid() + { + ulong newValue; + + // Lock rolling counter + this.rollingLock.lock(); + + newValue = this.rollingMid; + this.rollingMid++; + + // Unlock rolling counter + this.rollingLock.unlock(); + + return newValue; + } + /** * Constructs a new CoAP client to the * provided endpoint address and port.