From a606b19742a95d9fd035304368faaadb8d7cdc7e Mon Sep 17 00:00:00 2001 From: "Tristan B. Kildaire" Date: Thu, 24 Sep 2020 00:28:15 +0200 Subject: [PATCH] Implemented DChannel.leave(this, DConnection) --- source/dnetd/dchannel.d | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/source/dnetd/dchannel.d b/source/dnetd/dchannel.d index a20bd29..b02c54b 100644 --- a/source/dnetd/dchannel.d +++ b/source/dnetd/dchannel.d @@ -56,7 +56,26 @@ public class DChannel public void leave(DConnection client) { - + /* Lock the members list */ + memberLock.lock(); + + /* TODO: Get a better implementation */ + + /* Create a new list without the `client` */ + DConnection[] newMembers; + foreach(DConnection currentMember; members) + { + if(!(currentMember is client)) + { + newMembers ~= currentMember; + } + } + + /* Set it as the new list */ + members = newMembers; + + /* Unlock the members list */ + memberLock.unlock(); } public override string toString()