diff --git a/source/app.d b/source/app.d index 184ced4..f750a48 100644 --- a/source/app.d +++ b/source/app.d @@ -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) { diff --git a/source/client.d b/source/client.d index 3ce2ec7..348b783 100644 --- a/source/client.d +++ b/source/client.d @@ -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; diff --git a/source/notifications.d b/source/notifications.d index f323d58..a46d4e9 100644 --- a/source/notifications.d +++ b/source/notifications.d @@ -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]; + } } \ No newline at end of file