From c7fd5a6d3088b76b99b9095b1bd4ed7c2eba102b Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Mon, 28 Sep 2020 11:56:59 +0200 Subject: [PATCH] Migrated connectionQueue addition code to addConnection() --- source/dnetd/dserver.d | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/source/dnetd/dserver.d b/source/dnetd/dserver.d index 784a526..8e97b08 100644 --- a/source/dnetd/dserver.d +++ b/source/dnetd/dserver.d @@ -117,15 +117,8 @@ public class DServer : Thread /* Spawn a connection handler */ DConnection connection = new DConnection(this, socket); - /* Lock the connections list */ - connectionLock.lock(); - /* Add to the connection queue */ - connectionQueue ~= connection; - writeln("Added new connection to queue "~to!(string)(connection)); - - /* Unlock the connections list */ - connectionLock.unlock(); + addConnection(connection); } } @@ -142,6 +135,25 @@ public class DServer : Thread channelLock.unlock(); } + public void addConnection(DConnection connection) + { + /* Lock the connections list */ + connectionLock.lock(); + + /* Add to the connection queue */ + connectionQueue ~= connection; + writeln("Added new connection to queue "~to!(string)(connection)); + + /* Unlock the connections list */ + connectionLock.unlock(); + } + + /* TODO Remove connection */ + public void removeConnection(DConnection client) + { + + } + public DChannel getChannelByName(string channelName) { /* The channel */