From 75f3f7b867f17ffa0f86f43c1fccbe49cb330d6a Mon Sep 17 00:00:00 2001 From: "Tristan B. Velloza Kildaire" Date: Thu, 16 Mar 2023 18:38:06 +0200 Subject: [PATCH] Messages - Slightly improved trailer detection - Added some TODOs and notes Client - Log the key-value parameters and trailer --- source/birchwood/client/client.d | 3 +++ source/birchwood/protocol/messages.d | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/source/birchwood/client/client.d b/source/birchwood/client/client.d index ffc17b8..09a9463 100644 --- a/source/birchwood/client/client.d +++ b/source/birchwood/client/client.d @@ -140,6 +140,9 @@ public class Client : Thread if(commandReply.getReplyType() == ReplyType.RPL_BOUNCE) { logger.log("Take a look:\n\n"~commandReply.getParams()); + + logger.log("And here is key-value pairs: ", commandReply.getKVPairs()); + logger.log("And here is everything: ", commandReply.getTrailing()); } } diff --git a/source/birchwood/protocol/messages.d b/source/birchwood/protocol/messages.d index a85275b..b71b39d 100644 --- a/source/birchwood/protocol/messages.d +++ b/source/birchwood/protocol/messages.d @@ -293,6 +293,12 @@ public final class Message private string ppTrailing; private string[string] ppKVPairs; + /** + * NOTE: This needs more work with trailing support + * we must make sure we only look for lastInex of `:` + * where it is first cyaracter after space but NOT within + * an active parameter + */ private void parameterParse() { /* Only parse if there are params */ @@ -308,7 +314,10 @@ public final class Message string trailing; /* Find the first (and should be only) : (if any) */ - long trailingIdx = indexOf(params, ":"); + // TODO: Maybe i misunderstoof it as it appears in + // some key-value pairs as the value + // ... therefore let's just look for the last one + long trailingIdx = lastIndexOf(params, ":"); /* If there is trailing */ if(trailingIdx > -1) @@ -318,6 +327,8 @@ public final class Message /* Save the trailing text */ trailing = params[trailingIdx+1..params.length]; + + logger.debug_("Look at this trailing '"~trailing~"'"); } /* If there is no trailing */ else @@ -326,6 +337,8 @@ public final class Message kvPairs = params; } + // TODO: strip whitespace on either side of `kvPairs` + /* Generate the key-value pairs */ string[] pairs = split(kvPairs, " "); logger.debug_("Pairs: ", pairs);