mirror of
https://github.com/deavminet/skippy.git
synced 2025-02-01 10:51:30 +00:00
Added 'list' command
This commit is contained in:
parent
6feeb0a332
commit
1fee8c96b2
@ -70,6 +70,12 @@ void commandLine()
|
||||
writeln("Auth bad");
|
||||
}
|
||||
}
|
||||
/* If the command is `list` */
|
||||
else if(cmp(command, "list") == 0)
|
||||
{
|
||||
string[] channels = client.list();
|
||||
writeln(channels);
|
||||
}
|
||||
/* If the command is `join` */
|
||||
else if(cmp(command, "join") == 0)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@ import tristanable.manager : Manager;
|
||||
import std.socket;
|
||||
import std.stdio;
|
||||
import std.conv : to;
|
||||
import std.string : split;
|
||||
|
||||
public class DClient
|
||||
{
|
||||
@ -54,6 +55,23 @@ public class DClient
|
||||
return cast(bool)resp[0];
|
||||
}
|
||||
|
||||
public string[] list()
|
||||
{
|
||||
string[] channels;
|
||||
|
||||
byte[] data = [6];
|
||||
|
||||
manager.sendMessage(1, data);
|
||||
byte[] resp = manager.receiveMessage(1);
|
||||
|
||||
string channelList = cast(string)resp[1..resp.length];
|
||||
channels = split(channelList);
|
||||
|
||||
/* TODO: Throw error on resp[0] zero */
|
||||
|
||||
return channels;
|
||||
}
|
||||
|
||||
public Manager getManager()
|
||||
{
|
||||
return manager;
|
||||
|
@ -33,10 +33,23 @@ public class NotificationWatcher : Thread
|
||||
writeln(notificationReply.getData());
|
||||
string msg = cast(string)notificationReply.getData();
|
||||
writeln("!> "~msg);
|
||||
process(notificationReply.getData());
|
||||
}
|
||||
}
|
||||
|
||||
Thread.getThis().sleep(dur!("seconds")(2));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes an incoming notification
|
||||
* accordingly
|
||||
*/
|
||||
private void process(byte[] data)
|
||||
{
|
||||
/* TODO: Implement me */
|
||||
|
||||
/* TODO: Check notification type */
|
||||
byte notificationType = data[0];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user