1
0
mirror of https://github.com/deavminet/dnetd synced 2024-09-21 09:43:37 +02:00

WIP: Linking

This commit is contained in:
Tristan B. Kildaire 2021-01-30 14:17:01 +02:00
parent a8dc8fdd5b
commit 972023d2f3
2 changed files with 13 additions and 2 deletions

View File

@ -394,6 +394,12 @@ public class DConnection : Thread
connType = ConnectionType.SERVER; connType = ConnectionType.SERVER;
hasAuthed = true; 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 reply ~= [0]; // Testing for now
/* Send [nameLen, name] */ /* Send [nameLen, name] */

View File

@ -13,6 +13,7 @@ import gogga;
import core.thread; import core.thread;
import tristanable.encoding : DataMessage; import tristanable.encoding : DataMessage;
import bmessage : bSendMessage = sendMessage, bReceiveMessage = receiveMessage; import bmessage : bSendMessage = sendMessage, bReceiveMessage = receiveMessage;
import std.string : cmp;
/** /**
* Link manager * Link manager
@ -184,6 +185,10 @@ public final class DLink : Thread
gprintln("Server said his name is '"~name~"'", DebugType.WARNING); 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) else if(dataReply[0] == 1)
{ {
@ -270,9 +275,9 @@ public final class DMeyer
linksMutex.lock(); linksMutex.lock();
/* Search for this entry, only add it if it doens't exist */ /* 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; linkGood = false;
break; break;