From 972023d2f3dcf9f071e2155820e14706eb8c090c Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Sat, 30 Jan 2021 14:17:01 +0200 Subject: [PATCH] WIP: Linking --- source/dnetd/dconnection.d | 6 ++++++ source/dnetd/dlink.d | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index 4e90541..232aeaa 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -394,6 +394,12 @@ public class DConnection : Thread connType = ConnectionType.SERVER; hasAuthed = true; + /* Add to the meyer system (this connectio) */ + import dnetd.dlink : DLink; + DLink newLink = new DLink(server, serverNameIncoming, null); + bool linkSuccessful = server.getMeyer().attachLink(serverNameIncoming, newLink); + gprintln("Whether or not the link worked out (could be config error or possibly duplicate link): "~to!(string)(linkSuccessful)); + reply ~= [0]; // Testing for now /* Send [nameLen, name] */ diff --git a/source/dnetd/dlink.d b/source/dnetd/dlink.d index 3ece2f2..11a1347 100644 --- a/source/dnetd/dlink.d +++ b/source/dnetd/dlink.d @@ -13,6 +13,7 @@ import gogga; import core.thread; import tristanable.encoding : DataMessage; import bmessage : bSendMessage = sendMessage, bReceiveMessage = receiveMessage; +import std.string : cmp; /** * Link manager @@ -184,6 +185,10 @@ public final class DLink : Thread gprintln("Server said his name is '"~name~"'", DebugType.WARNING); + /* Attempt to attach server */ + status = server.getMeyer().attachLink(name, this); + gprintln("Outbound link status: "~to!(string)(status)); + } else if(dataReply[0] == 1) { @@ -270,9 +275,9 @@ public final class DMeyer linksMutex.lock(); /* Search for this entry, only add it if it doens't exist */ - foreach(DLink link; links) + foreach(DLink currentLink; links) { - if(cmp(link.getName(), serverName) == 0) + if(cmp(currentLink.getName(), serverName) == 0) { linkGood = false; break;