From a5f85960626f15954db8769e9343266060a92d72 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Mon, 28 Sep 2020 10:12:13 +0200 Subject: [PATCH] Fixed protocol type number 5 --- source/dnetd/dconnection.d | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index 0e275c0..9e06142 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -118,7 +118,7 @@ public class DConnection : Thread receivedMessage = DataMessage.decode(receivedBytes); /* Process the message */ - process(receivedMessage); + process(receivedMessage); /* TODO: Tristanable needs reserved-tag support (client-side concern) */ } @@ -359,23 +359,22 @@ public class DConnection : Thread bool status = true; /* Get the type of message */ - byte messageType = message.data[0]; + byte messageType = message.data[1]; + + /* Get the location length */ + byte locationLength = message.data[2]; /* Get the channel/person name */ - string destination; - ulong i = 0; - while(message.data[1+i] != cast(byte)0) - { - destination ~= message.data[1+i]; - i++; - } + string destination = cast(string)message.data[3..cast(ulong)3+locationLength]; - /* Get the message (offset from null-terminator, hence +1 at the end) */ - string msg = cast(string)message.data[1+i+1..message.data.length]; + /* Get the message */ + string msg = cast(string)message.data[cast(ulong)3+locationLength..message.data.length]; /* Send status */ bool sendStatus; + writeln("bababoi b4"); + /* If we are sending to a user */ if(messageType == cast(byte)0) { @@ -408,6 +407,8 @@ public class DConnection : Thread /* TODO: Handling here, should we make the user wait? */ + + writeln("bababoi after"); /* Encode the reply */ /* TODO: */ reply = [status];