Use gogga for some debug messages

This commit is contained in:
Tristan B. Kildaire 2021-01-28 11:08:18 +02:00
parent 27c42711e0
commit 1420e8e86f
3 changed files with 21 additions and 17 deletions

View File

@ -4,8 +4,9 @@
],
"copyright": "Copyright © 2020, Tristan B. Kildaire",
"dependencies": {
"gogga": "0.0.2",
"gtk-d": "3.9.0",
"libdnet": "0.1.17"
"libdnet": "0.2.3"
},
"description": "GTK graphical DNET client",
"license": "GPL v3",

View File

@ -2,6 +2,7 @@
"fileVersion": 1,
"versions": {
"bformat": "1.0.8",
"gogga": "0.0.2",
"gtk-d": "3.9.0",
"libdnet": "0.1.17",
"tristanable": "0.1.1"

View File

@ -19,6 +19,8 @@ import gtk.Notebook;
import std.conv;
import gogga;
public final class Connection : Thread
{
private GUI gui;
@ -122,7 +124,8 @@ public final class Connection : Thread
{
/* Receive a notification */
byte[] notificationData = client.awaitNotification();
writeln(notificationData);
gprintln("A new notification has arrived");
gprintln("Notification data: "~to!(string)(notificationData));
te();
// import std.conv;
@ -151,45 +154,38 @@ public final class Connection : Thread
}
}
/**
* Processes an incoming notification
* accordingly
*/
private void process(byte[] data)
{
/* TODO: Implement me */
/* TODO: Check notification type */
/* Get the notification type */
ubyte notificationType = data[0];
gprintln("NotificationType: "~to!(string)(notificationType));
/* For normal message (to channel or user) */
if(notificationType == 0)
{
/* TODO: Decode using tristanable */
writeln("new message");
writeln(data);
/* TODO: Handle private messages */
/* Decode is a test for assuming channel message received */
data = data[1..data.length];
/* Decode the [usernameLength, username] */
ubyte usernameLength = data[1];
writeln(usernameLength);
gprintln("NormalMessage: (Username length): "~to!(string)(usernameLength));
string username = cast(string)data[2..2+usernameLength];
writeln(username);
gprintln("NormalMessage: (Username): "~username);
/* Decode the [channelLength, channel] */
ubyte channelLength = data[2+usernameLength];
writeln(channelLength);
gprintln("NormalMessage: (Channel length): "~to!(string)(channelLength));
string channel = cast(string)data[2+usernameLength+1..2+usernameLength+1+channelLength];
writeln(channel);
gprintln("NormalMessage: (Channel): "~channel);
findChannel(channel).receiveMessage(username, cast(string)data[2+usernameLength+1+channelLength..data.length]);
writeln("hdsfhdk");
}
/* Channel notification (ntype=1) */
else if(notificationType == 1)
@ -240,6 +236,12 @@ public final class Connection : Thread
}
public void joinChannel(string channelName)
{
/* Check if we have joined this channel already */