Finished OOP

This commit is contained in:
Tristan B. Kildaire 2021-01-27 23:05:06 +02:00
parent 33c01a53ed
commit de3006ac35
1 changed files with 20 additions and 11 deletions

View File

@ -649,23 +649,32 @@ public final class DClient
/* Send the protocol data */ /* Send the protocol data */
DataMessage protocolDataMsg = new DataMessage(reqRepQueue.getTag(), protocolData); DataMessage protocolDataMsg = new DataMessage(reqRepQueue.getTag(), protocolData);
bSendMessage(socket, protocolDataMsg.encode()); bool status = bSendMessage(socket, protocolDataMsg.encode());
/* Receive the server's response */ /* If the send worked */
byte[] resp = reqRepQueue.dequeue().getData(); if(status)
/* Check if the operation completed successfully */
if(resp[0])
{ {
/* Set the message of the day */ /* Receive the server's response */
motd = cast(string)resp[1..resp.length]; 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 else
{ {
/* TODO: Error handling */ throw new DNetworkError("getmotd");
} }
return motd;
} }
/** /**