From 819abf1faa37d38ca5ef74ad417e10de78a331ed Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Sun, 27 Sep 2020 23:40:10 +0200 Subject: [PATCH] Encode length --- source/app.d | 2 +- source/client.d | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/app.d b/source/app.d index 8889706..c1233bf 100644 --- a/source/app.d +++ b/source/app.d @@ -178,7 +178,7 @@ void commandLine() } else { - //client.sendMessage() + dclient.sendMessage(false, currentChannel, commandLine); } } diff --git a/source/client.d b/source/client.d index 1431a5b..3e13a3d 100644 --- a/source/client.d +++ b/source/client.d @@ -102,7 +102,7 @@ public class DClient public bool sendMessage(bool isUser, string location, string message) { /* The protocol data to send */ - byte[] protocolData; + byte[] protocolData = [5]; /** * If we are sending to a user then the @@ -113,6 +113,12 @@ public class DClient */ protocolData ~= [!isUser]; + /* Encode the length of `location` */ + protocolData ~= [cast(byte)location.length]; + + /* Encode the user/channel name */ + protocolData ~= cast(byte[])location; + /* Encode the message */ protocolData ~= cast(byte[])message;