Encode length

This commit is contained in:
Tristan B. Kildaire 2020-09-27 23:40:10 +02:00
parent 538607fa56
commit 819abf1faa
2 changed files with 8 additions and 2 deletions

View File

@ -178,7 +178,7 @@ void commandLine()
}
else
{
//client.sendMessage()
dclient.sendMessage(false, currentChannel, commandLine);
}
}

View File

@ -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;