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

Fixed bug whereby newlu created channels were not added to the global channel list

This commit is contained in:
Tristan B. Kildaire 2020-09-25 09:25:37 +02:00
parent d18e6f4944
commit bf74c74891
2 changed files with 26 additions and 1 deletions

View File

@ -31,6 +31,8 @@ public class DChannel
{ {
/* Initialize the lock */ /* Initialize the lock */
memberLock = new Mutex(); memberLock = new Mutex();
this.name = name;
} }
public string getName() public string getName()
@ -50,9 +52,12 @@ public class DChannel
* TODO: Error handling if the calling DConnection fails midway * TODO: Error handling if the calling DConnection fails midway
* and doesn't unlock it * and doesn't unlock it
*/ */
writeln(this);
/* Add the client */ /* Add the client */
members ~= client; members ~= client;
import std.stdio;
writeln(members);
/* Unlock the members list */ /* Unlock the members list */
memberLock.unlock(); memberLock.unlock();

View File

@ -18,6 +18,7 @@ import core.sync.mutex : Mutex;
import dnetd.dserver : DServer; import dnetd.dserver : DServer;
import std.string : split; import std.string : split;
import dnetd.dchannel : DChannel; import dnetd.dchannel : DChannel;
import std.conv : to;
public class DConnection : Thread public class DConnection : Thread
{ {
@ -226,6 +227,8 @@ public class DConnection : Thread
{ {
/* TODO: Thread safety for name choice */ /* TODO: Thread safety for name choice */
channel = new DChannel(channelName); channel = new DChannel(channelName);
server.addChannel(this, channel);
} }
/* Join the channel */ /* Join the channel */
@ -370,7 +373,8 @@ public class DConnection : Thread
} }
else else
{ {
byte[] reply = [false];
writeSocket(tag, reply);
} }
} }
} }
@ -390,4 +394,20 @@ public class DConnection : Thread
{ {
return username; return username;
} }
public override string toString()
{
string toStr = to!(string)(connType)~"hjhf";
if(connType == ConnectionType.CLIENT)
{
toStr = toStr ~ getUsername();
}
else
{
/* TODO Implement me */
}
return toStr;
}
} }