From 74248756765dbe2d68f6cf2ec83c0a5a370ecec3 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Mon, 28 Sep 2020 22:00:31 +0200 Subject: [PATCH] Direct messages implemented --- source/dnetd/dconnection.d | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index f97cbb5..00b2444 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -484,11 +484,28 @@ public class DConnection : Thread /* Find the user to send to */ DConnection user = server.findUser(username); + writeln("sendUserMessage(): ", user); + /* If the user was found */ if(user) { + /* The protocol data to send */ + byte[] protocolData; + + /* Set the sub-type (ntype=0) */ + protocolData ~= [0]; + + /* Encode the sender's length */ + protocolData ~= [cast(byte)username.length]; + + /* Encode the username */ + protocolData ~= cast(byte[])username; + + /* Encode the message */ + protocolData ~= cast(byte[])message; + /* Send the messge */ - /* TODO: Implement me */ + user.writeSocket(0, protocolData); /* TODO: Return value should be based off message send success */