Implemented 'list' command

This commit is contained in:
Tristan B. Kildaire 2020-09-24 12:32:00 +02:00
parent af167f47e3
commit 7caf0aa22f
2 changed files with 33 additions and 0 deletions

View File

@ -237,6 +237,34 @@ public class DConnection : Thread
/* TODO: Implement me, use return value */
writeSocket(tag, reply);
}
/* If `list` command (requires: authed) */
else if(commandByte == 6 && hasAuthed)
{
/* Get all channels */
DChannel[] channels = server.getChannels();
/* Generate a list of channel names (CSV) */
string channelList;
for(ulong i = 0; i < channels.length; i++)
{
if(i == channels.length-1)
{
channelList ~= channels[i].getName();
}
else
{
channelList ~= channels[i].getName()~",";
}
}
/* TODO: Reply */
/* Encode the reply */
byte[] reply = [true];
reply ~= channelList;
/* TODO: Implement me, use return value */
writeSocket(tag, reply);
}
/* TODO: Handle this case */
else
{

View File

@ -147,4 +147,9 @@ public class DServer : Thread
return null;
}
public DChannel[] getChannels()
{
return channels;
}
}