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

Refactored

This commit is contained in:
Tristan B. Kildaire 2021-01-30 16:27:41 +02:00
parent 315fcb8ac9
commit 1e3ca829fb
2 changed files with 25 additions and 4 deletions

View File

@ -177,6 +177,25 @@ public class DConnection : Thread
{ {
gprintln(to!(string)(this)~" Cleaning up connection..."); gprintln(to!(string)(this)~" Cleaning up connection...");
/* Leave all channels this connetion was a member of */
cleanUp_channels();
/* Remove this user from the connection queue */
server.removeConnection(this);
gprintln(to!(string)(this)~" Connection cleaned up");
}
/**
* Part of the clean up process - `cleanUp()`
*
* Will leave all channels this connection is
* a member of
*/
private void cleanUp_channels()
{
gprintln(to!(string)(this)~" Leaving all channels...");
/* Remove this user from all channels he is in */ /* Remove this user from all channels he is in */
DChannel[] channels = server.getChannels(); DChannel[] channels = server.getChannels();
@ -191,11 +210,8 @@ public class DConnection : Thread
gprintln(to!(string)(this)~" Leaving '"~currentChannel.getName()~"'..."); gprintln(to!(string)(this)~" Leaving '"~currentChannel.getName()~"'...");
} }
} }
/* Remove this user from the connection queue */
server.removeConnection(this);
gprintln(to!(string)(this)~" Connection cleaned up"); gprintln(to!(string)(this)~" Leaving all channels... [done]");
} }
/* TODO: add mutex for writing with message and funciton for doing so */ /* TODO: add mutex for writing with message and funciton for doing so */

View File

@ -227,6 +227,7 @@ public final class DLink : Thread
this(server, name, address); this(server, name, address);
/* Save connection */ /* Save connection */
//this.connection = connection;
} }
public string getName() public string getName()
@ -258,6 +259,9 @@ public final class DMeyer : Thread
start(); start();
} }
/**
* Every 3 seconds information on what servers are linked will be printed out
*/
private void worker() private void worker()
{ {
while(true) while(true)
@ -265,6 +269,7 @@ public final class DMeyer : Thread
linksMutex.lock(); linksMutex.lock();
gprintln("Linked servers: "~to!(string)(links), DebugType.WARNING); gprintln("Linked servers: "~to!(string)(links), DebugType.WARNING);
linksMutex.unlock(); linksMutex.unlock();
Thread.sleep(dur!("seconds")(3)); Thread.sleep(dur!("seconds")(3));
} }
} }