From 4f1f843d43218548f9248df56aa0039f34de913b Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Sun, 24 Sep 2023 23:57:26 +0200 Subject: [PATCH] CoapPacket - Added stub `orderOptions()` type which will re-order the current options and then return a new re-ordered array for encoding properly - Added stub `encodeOption(CoapOption)` which returns the encoded option as a `ubyte[]` - `getBytes()` has stub code to call `orderOption()`, iterate over itsm items and call `encodeOption()` on each --- source/doap/protocol/packet.d | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/doap/protocol/packet.d b/source/doap/protocol/packet.d index 2432e91..160aed2 100644 --- a/source/doap/protocol/packet.d +++ b/source/doap/protocol/packet.d @@ -89,6 +89,10 @@ public class CoapPacket } // FIXME: Add options encoding + foreach(CoapOption option; orderOptions()) + { + encoded ~= encodeOption(option); + } // Set the payload marker encoded ~= PAYLOAD_MARKER; @@ -99,6 +103,20 @@ public class CoapPacket return encoded; } + // TODO: Make public in the future + private static ubyte[] encodeOption(CoapOption option) + { + // TODO: Implement this + return []; + } + + private CoapOption[] orderOptions() + { + // TODO: Implement ordering here + return this.options; + } + + public void setType(MessageType type) { this.type = type;