dconnection now uses `gprintln`

This commit is contained in:
Tristan B. Kildaire 2020-10-29 11:26:07 +02:00
parent 170511a934
commit 1466820ee1
1 changed files with 12 additions and 11 deletions

View File

@ -21,6 +21,7 @@ import dnetd.dchannel : DChannel;
import std.conv : to; import std.conv : to;
import std.stdio : writeln; import std.stdio : writeln;
import std.algorithm : reverse; import std.algorithm : reverse;
import gogga;
public class DConnection : Thread public class DConnection : Thread
{ {
@ -168,7 +169,7 @@ public class DConnection : Thread
else else
{ {
/* TODO: Error handling */ /* TODO: Error handling */
writeln("Error with receive: "~to!(string)(this)); gprintln("Error with receive: "~to!(string)(this), DebugType.ERROR);
break; break;
} }
} }
@ -179,7 +180,7 @@ public class DConnection : Thread
private void cleanUp() private void cleanUp()
{ {
writeln(to!(string)(this)~" Cleaning up connection..."); grpintln(to!(string)(this)~" Cleaning up connection...");
/* Remove this user from all channels he is in */ /* Remove this user from all channels he is in */
DChannel[] channels = server.getChannels(); DChannel[] channels = server.getChannels();
@ -192,14 +193,14 @@ public class DConnection : Thread
{ {
/* Leave the channel */ /* Leave the channel */
currentChannel.leave(this); currentChannel.leave(this);
writeln(to!(string)(this)~" Leaving '"~currentChannel.getName()~"'..."); gprintln(to!(string)(this)~" Leaving '"~currentChannel.getName()~"'...");
} }
} }
/* Remove this user from the connection queue */ /* Remove this user from the connection queue */
server.removeConnection(this); server.removeConnection(this);
writeln(to!(string)(this)~" Connection cleaned up"); gprintln(to!(string)(this)~" Connection cleaned up");
} }
/* TODO: add mutex for writing with message and funciton for doing so */ /* TODO: add mutex for writing with message and funciton for doing so */
@ -223,18 +224,18 @@ public class DConnection : Thread
/* Create the tagged message */ /* Create the tagged message */
DataMessage message = new DataMessage(tag, data); DataMessage message = new DataMessage(tag, data);
writeln("writeSocket: mutex lock"); gprintln("writeSocket: mutex lock");
/* Lock the write mutex */ /* Lock the write mutex */
writeLock.lock(); writeLock.lock();
/* Send the message */ /* Send the message */
writeln("writeSocket: Data: "~to!(string)(data)~" Tag: "~to!(string)(tag)); gprintln("writeSocket: Data: "~to!(string)(data)~" Tag: "~to!(string)(tag));
status = sendMessage(socket, message.encode()); status = sendMessage(socket, message.encode());
/* Unlock the write mutex */ /* Unlock the write mutex */
writeLock.unlock(); writeLock.unlock();
writeln("writeSocket: mutex unlock"); gprintln("writeSocket: mutex unlock");
return status; return status;
} }
@ -342,7 +343,7 @@ public class DConnection : Thread
* between commands and async notifications * between commands and async notifications
*/ */
long tag = message.tag; long tag = message.tag;
writeln("tag:", tag); gprintln("tag: "~ to!(string)(tag));
/* The reply */ /* The reply */
byte[] reply; byte[] reply;
@ -350,7 +351,7 @@ public class DConnection : Thread
/* Get the command */ /* Get the command */
byte commandByte = message.data[0]; byte commandByte = message.data[0];
Command command = getCommand(commandByte); Command command = getCommand(commandByte);
writeln(to!(string)(this)~" ~> "~to!(string)(command)); gprintln(to!(string)(this)~" ~> "~to!(string)(command));
/* If `auth` command (requires: unauthed) */ /* If `auth` command (requires: unauthed) */
if(command == Command.AUTH && !hasAuthed) if(command == Command.AUTH && !hasAuthed)
@ -894,7 +895,7 @@ public class DConnection : Thread
/* Find the user to send to */ /* Find the user to send to */
DConnection user = server.findUser(username); /*TODO: Ins erver not just use it directly */ DConnection user = server.findUser(username); /*TODO: Ins erver not just use it directly */
writeln("sendUserMessage(): ", user); gprintln("sendUserMessage(): ", user);
/* If the user was found */ /* If the user was found */
if(user) if(user)
@ -954,7 +955,7 @@ public class DConnection : Thread
/* The status message */ /* The status message */
string statusMessage; string statusMessage;
writeln("hfsjkhfjsdkhfdskj"); gprintln("hfsjkhfjsdkhfdskj");
/* Lock the status message mutex */ /* Lock the status message mutex */
statusMessageLock.lock(); statusMessageLock.lock();