Added 'getMemberCount(string)'

This commit is contained in:
Tristan B. Kildaire 2020-09-29 18:34:52 +02:00
parent 9f89f35e6f
commit 1ad619e0e1
1 changed files with 37 additions and 0 deletions

View File

@ -174,6 +174,43 @@ public final class DClient
return cast(bool)resp[0];
}
/**
* Returns the count of members in the
* given channel
*/
public ulong getMemberCount(string channelName)
{
/* The member count */
long memberCount;
/* The protocol data to send */
byte[] protocolData = [8];
/* Encode the channel name */
protocolData ~= cast(byte[])channelName;
/* Send the protocol data */
manager.sendMessage(i, protocolData);
/* Receive the server's response */
byte[] resp = manager.receiveMessage(i);
/* Check if the operation completed successfully */
if(resp[0])
{
memberCount = *cast(long*)resp[1..resp.length].ptr;
}
else
{
/* TODO: Error handling */
}
/* Set next available tag */
i++;
return memberCount;
}
/**
* Disconnect from the server
*