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

Move code to the thread worker

Start thread worker
This commit is contained in:
Tristan B. Kildaire 2021-01-29 21:12:27 +02:00
parent 0c4ca8e55a
commit 668790e33b
2 changed files with 31 additions and 3 deletions

View File

@ -86,6 +86,12 @@ void main(string[] args)
/* Start the server (TODO: This should start Meyer) */ /* Start the server (TODO: This should start Meyer) */
dserver.startServer(); dserver.startServer();
foreach(DLink link; serverLinks)
{
link.start();
}
} }
catch(JSONException e) catch(JSONException e)
{ {

View File

@ -84,8 +84,7 @@ public final class DLink : Thread
/* Create an outbound connection */ /* Create an outbound connection */
/* TODO: Fuuuuuuuuuuuuuuuuuuuck handling of shit here bababooey and not in dconnection.d as we would have done below */ /* TODO: Fuuuuuuuuuuuuuuuuuuuck handling of shit here bababooey and not in dconnection.d as we would have done below */
/* Initialize a new outbound connection */
initializeOutboundConnection();
} }
/** /**
@ -95,9 +94,29 @@ public final class DLink : Thread
{ {
/* Open a connection to the server */ /* Open a connection to the server */
import std.socket; import std.socket;
import gogga;
import core.thread;
Socket socket = new Socket(address.addressFamily, SocketType.STREAM, ProtocolType.TCP); Socket socket = new Socket(address.addressFamily, SocketType.STREAM, ProtocolType.TCP);
gprintln(address);
while(true)
{
try
{
socket.connect(address); socket.connect(address);
break;
}
catch(SocketOSException)
{
gprintln("Could not link with server "~name~"!", DebugType.ERROR);
Thread.sleep(dur!("seconds")(3));
}
}
@ -105,6 +124,9 @@ public final class DLink : Thread
private void outboundWorker() private void outboundWorker()
{ {
/* Initialize a new outbound connection */
initializeOutboundConnection();
/* TODO: Implement me */ /* TODO: Implement me */
while(true) while(true)
{ {