From 7e18e8e6fc070c1a3dca5d94feb81a86226b5829 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Tue, 20 Oct 2020 23:16:50 +0200 Subject: [PATCH] My fok marelize --- source/dnetd/dchannel.d | 15 ++++++++++++++- source/dnetd/dconnection.d | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/source/dnetd/dchannel.d b/source/dnetd/dchannel.d index 9c472f4..da4e22c 100644 --- a/source/dnetd/dchannel.d +++ b/source/dnetd/dchannel.d @@ -269,7 +269,20 @@ public class DChannel * byte length of name of channel/person (dm case) * message-bytes */ - msg ~= [cast(byte)1,(cast(byte)sender.getUsername().length)]~cast(byte[])sender.getUsername()~cast(byte[])message; + + /* Set mode to channel message */ + msg ~= [cast(byte)1]; + + /* Encode the [usernameLength, username] */ + msg ~= [(cast(byte)sender.getUsername().length)]; + msg ~= cast(byte[])sender.getUsername(); + + /* Encode the [channelLength, channel] */ + msg ~= [(cast(byte)name.length)]; + msg ~= cast(byte[])name; + + /* Encode the message */ + msg ~= cast(byte[])message; /* Send the message to everyone else in the channel */ foreach(DConnection member; members) diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index 6723f7e..85bcedc 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -766,7 +766,20 @@ public class DConnection : Thread /* If `delete_user_prop` (requires: authed, client) */ else if(command == Command.DELETE_USER_PROP && hasAuthed && connType == ConnectionType.CLIENT) { + /* Get the property */ + string property = cast(string)message.data[1..message.data.length]; + /* Check if the key exists */ + bool keyExists = isProperty(property); + + /* If the property exists */ + if(keyExists) + { + /* Delete the property */ + deleteProperty(property); + } + + reply ~= [keyExists]; } /* If `is_user_prop` (requires: authed, client) */ else if(command == Command.IS_USER_PROP && hasAuthed && connType == ConnectionType.CLIENT) @@ -824,6 +837,7 @@ public class DConnection : Thread private bool authenticate(string username, string password) { /* TODO: Implement me */ + this.username = username; return true; }