From d040dcf926c77b908e0fcd5d2290e8e7d6cfc407 Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Tue, 20 Oct 2020 10:26:47 +0200 Subject: [PATCH] Implemented `getProperty` command --- source/libdnet/dclient.d | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/source/libdnet/dclient.d b/source/libdnet/dclient.d index 0099e12..44651c1 100644 --- a/source/libdnet/dclient.d +++ b/source/libdnet/dclient.d @@ -222,6 +222,35 @@ public final class DClient return properties; } + /** + * Get a property's value + */ + public string getProperty(string user, string property) + { + /* The property's value */ + string propertyValue; + + /* The protocol data to send */ + byte[] data = [16]; + data ~= user~","~property; + + /* Send the protocol data */ + DataMessage protocolData = new DataMessage(reqRepQueue.getTag(), data); + bSendMessage(socket, protocolData.encode()); + + /* Receive the server's response */ + byte[] resp = reqRepQueue.dequeue().getData(); + + /* If it worked */ + if(cast(bool)resp[0]) + { + /* Get the property line */ + propertyValue = cast(string)resp[1..resp.length]; + } + + return propertyValue; + } + /** * Lists all the channels on the server