From de3006ac35b7abdd98a435239216ad36cda6e86d Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Wed, 27 Jan 2021 23:05:06 +0200 Subject: [PATCH] Finished OOP --- source/libdnet/client.d | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/source/libdnet/client.d b/source/libdnet/client.d index 2b3081a..8c4ce45 100644 --- a/source/libdnet/client.d +++ b/source/libdnet/client.d @@ -649,23 +649,32 @@ public final class DClient /* Send the protocol data */ DataMessage protocolDataMsg = new DataMessage(reqRepQueue.getTag(), protocolData); - bSendMessage(socket, protocolDataMsg.encode()); + bool status = bSendMessage(socket, protocolDataMsg.encode()); - /* Receive the server's response */ - byte[] resp = reqRepQueue.dequeue().getData(); - - /* Check if the operation completed successfully */ - if(resp[0]) + /* If the send worked */ + if(status) { - /* Set the message of the day */ - motd = cast(string)resp[1..resp.length]; + /* Receive the server's response */ + byte[] resp = reqRepQueue.dequeue().getData(); + + /* Check if the operation completed successfully */ + if(resp[0]) + { + /* Set the message of the day */ + motd = cast(string)resp[1..resp.length]; + } + else + { + throw new DClientException("Get motd error"); + } + + return motd; } + /* If the list failed */ else { - /* TODO: Error handling */ + throw new DNetworkError("getmotd"); } - - return motd; } /**