diff --git a/dub.json b/dub.json index 86fe4a3..011afeb 100644 --- a/dub.json +++ b/dub.json @@ -4,7 +4,7 @@ ], "copyright": "Copyright © 2020, Tristan B. Kildaire", "dependencies": { - "libdnet": "~>0.1.0", + "libdnet": "~>0.1.2", }, "description": "dnet client", "license": "GPLv3", diff --git a/dub.selections.json b/dub.selections.json index b3a5f71..a22a2c1 100644 --- a/dub.selections.json +++ b/dub.selections.json @@ -2,7 +2,7 @@ "fileVersion": 1, "versions": { "bformat": "1.0.8", - "libdnet": "0.1.0", - "tristanable": "0.1.0" + "libdnet": "0.1.2", + "tristanable": "0.1.1" } } diff --git a/source/app.d b/source/app.d index 7683a33..5d2793b 100644 --- a/source/app.d +++ b/source/app.d @@ -4,7 +4,7 @@ import std.socket; import libdnet.dclient : DClient; import std.string : cmp, split, strip; import std.conv : to; -import notifications; +// import notifications; import std.file; import std.json; @@ -13,7 +13,7 @@ JSONValue config; /* Current conneciton */ DClient dclient; -NotificationWatcher dnotifications; +//NotificationWatcher dnotifications; Mode currentMode; @@ -128,7 +128,7 @@ void commandLine() addr = getAddress(address, to!(ushort)(port))[0]; writeln("Connecting to "~to!(string)(addr)~"..."); dclient = new DClient(addr); - dnotifications= new NotificationWatcher(dclient.getManager()); + //dnotifications= new NotificationWatcher(dclient.getManager()); writeln("Connected!"); /* Get the message of the day */ diff --git a/source/notifications.d b/source/notifications.d index b517f77..c0a132c 100644 --- a/source/notifications.d +++ b/source/notifications.d @@ -1,91 +1,91 @@ -import core.thread : Thread; -import tristanable.manager; -import tristanable.notifications; -import std.stdio; -import core.time : dur; -import tristanable.encoding; +// import core.thread : Thread; +// import tristanable.manager; +// import tristanable.notifications; +// import std.stdio; +// import core.time : dur; +// import tristanable.encoding; -public class NotificationWatcher : Thread -{ - private Manager manager; +// public class NotificationWatcher : Thread +// { +// private Manager manager; - this(Manager manager) - { - super(&worker); +// this(Manager manager) +// { +// super(&worker); - this.manager = manager; - manager.reserveTag(0); +// this.manager = manager; +// manager.reserveTag(0); - start(); - } +// start(); +// } - private void worker() - { - while(true) - { - /* Check for notifications every 2 seconds */ - NotificationReply[] notifications =manager.popNotifications(); +// private void worker() +// { +// while(true) +// { +// /* Check for notifications every 2 seconds */ +// NotificationReply[] notifications =manager.popNotifications(); - if(notifications.length) - { - //writeln(notifications); - foreach(NotificationReply notificationReply; notifications) - { - //writeln(notificationReply.getData()); - string msg = cast(string)notificationReply.getData(); - writeln("!> "~msg); - process(notificationReply.getData()); - } - } +// if(notifications.length) +// { +// //writeln(notifications); +// foreach(NotificationReply notificationReply; notifications) +// { +// //writeln(notificationReply.getData()); +// string msg = cast(string)notificationReply.getData(); +// writeln("!> "~msg); +// process(notificationReply.getData()); +// } +// } - Thread.getThis().sleep(dur!("seconds")(2)); - } - } +// Thread.getThis().sleep(dur!("seconds")(2)); +// } +// } - /** - * Processes an incoming notification - * accordingly - */ - private void process(byte[] data) - { - /* TODO: Implement me */ +// /** +// * Processes an incoming notification +// * accordingly +// */ +// private void process(byte[] data) +// { +// /* TODO: Implement me */ - /* TODO: Check notification type */ - byte notificationType = data[0]; +// /* TODO: Check notification type */ +// byte notificationType = data[0]; - /* For normal message (to channel or user) */ - if(notificationType == cast(byte)0) - { - /* TODO: Decode using tristanable */ - writeln("new message"); - } - /* Channel notification (ntype=1) */ - else if(notificationType == cast(byte)1) - { - /* TODO: Decode using tristanable */ - /* TODO: Get the username of the user that left */ - //writeln("user left/join message"); +// /* For normal message (to channel or user) */ +// if(notificationType == cast(byte)0) +// { +// /* TODO: Decode using tristanable */ +// writeln("new message"); +// } +// /* Channel notification (ntype=1) */ +// else if(notificationType == cast(byte)1) +// { +// /* TODO: Decode using tristanable */ +// /* TODO: Get the username of the user that left */ +// //writeln("user left/join message"); - /* Get the sub-type */ - byte subType = data[1]; +// /* Get the sub-type */ +// byte subType = data[1]; - /* If the notification was leave (stype=0) */ - if(subType == cast(byte)0) - { - string username = cast(string)data[2..data.length]; - writeln("<-- "~username~" left the channel"); - } - /* If the notification was join (stype=1) */ - else if(subType == cast(byte)1) - { - string username = cast(string)data[2..data.length]; - writeln("--> "~username~" joined the channel"); - } - /* TODO: Unknown */ - else - { +// /* If the notification was leave (stype=0) */ +// if(subType == cast(byte)0) +// { +// string username = cast(string)data[2..data.length]; +// writeln("<-- "~username~" left the channel"); +// } +// /* If the notification was join (stype=1) */ +// else if(subType == cast(byte)1) +// { +// string username = cast(string)data[2..data.length]; +// writeln("--> "~username~" joined the channel"); +// } +// /* TODO: Unknown */ +// else +// { - } - } - } -} \ No newline at end of file +// } +// } +// } +// } \ No newline at end of file