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

Moved code for outbound server linking to DServer

This commit is contained in:
Tristan B. Kildaire 2021-01-29 21:21:59 +02:00
parent ea36ba240d
commit 905ad50188
3 changed files with 26 additions and 19 deletions

View File

@ -85,13 +85,6 @@ void main(string[] args)
/* Start the server (TODO: This should start Meyer) */ /* Start the server (TODO: This should start Meyer) */
dserver.startServer(); dserver.startServer();
/* Start all DLink outbound handlers (TODO: Move to DServer) */
foreach(DLink link; serverLinks)
{
link.start();
}
} }
catch(JSONException e) catch(JSONException e)
{ {

View File

@ -175,6 +175,9 @@ public final class DMeyer
/* Open a connection to the server */ /* Open a connection to the server */
/* TODO: Open connections to all servers we are yet to open a connection to (check the `links` array) */ /* TODO: Open connections to all servers we are yet to open a connection to (check the `links` array) */
this.links = links;
} }
/** /**
@ -191,18 +194,8 @@ public final class DMeyer
linksMutex = new Mutex(); linksMutex = new Mutex();
} }
/** public DLink[] getOutboundLinks()
* Adds a peer to the links list
*/
public void addLink(DLink newLink)
{ {
/* Lock the list */ return links;
linksMutex.lock();
/* Add the link */
links ~= newLink;
/* Unlock the list */
linksMutex.unlock();
} }
} }

View File

@ -162,6 +162,27 @@ public class DServer : Thread
{ {
/* Start the listener starter */ /* Start the listener starter */
start(); start();
/* Start outbound server linking */
startOutboundLinks();
gprintln("poes");
}
/**
* This will look at the link manager (DMeyer)
* and loop through each DLink in it and
* establish an outbound connection and therefore
* connection handler for each of them
*/
private void startOutboundLinks()
{
DLink[] serverLinks = meyerSS.getOutboundLinks();
/* Start all DLink outbound handlers (TODO: Move to DServer) */
foreach(DLink link; serverLinks)
{
link.start();
}
} }
public void addChannel(DConnection causer, DChannel channel) public void addChannel(DConnection causer, DChannel channel)