From aa41a13aed38f0d8ad889aa3678feb1547369043 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Sun, 27 Sep 2020 19:50:39 +0200 Subject: [PATCH] Refactored bool 'status' after user/channel send --- source/dnetd/dchannel.d | 8 ++++++-- source/dnetd/dconnection.d | 3 +-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/dnetd/dchannel.d b/source/dnetd/dchannel.d index ba083e1..1316f1d 100644 --- a/source/dnetd/dchannel.d +++ b/source/dnetd/dchannel.d @@ -129,8 +129,9 @@ public class DChannel memberLock.unlock(); } - public void sendMessage(DConnection sender, string message) + public bool sendMessage(DConnection sender, string message) { + bool status; /* TODO: Generate message */ /* TODO: Spec out in protocol */ /* TODO: Reserved tag 0 for notifications */ @@ -152,12 +153,15 @@ public class DChannel { /* Send the message */ writeln("Delivering message for channel '"~name~"' to user '"~member.getUsername()~"'..."); - bool status = member.writeSocket(0, msg); + status = member.writeSocket(0, msg); writeln("Delivered message for channel '"~name~"' to user '"~member.getUsername()~"'!"); /* TODO: Errors from status */ } } + + + return status; } public override string toString() diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index 52e5902..0e275c0 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -381,7 +381,6 @@ public class DConnection : Thread { /* Send the message to the user */ sendStatus = sendUserMessage(destination, msg); - reply = [sendStatus]; } /* If we are sending to a channel */ else if(messageType == cast(ubyte)1) @@ -393,7 +392,7 @@ public class DConnection : Thread if(channel) { /* TODO Implemet me */ - channel.sendMessage(this, msg); + sendStatus = channel.sendMessage(this, msg); } /* If the channel does not exist */ else