diff --git a/source/dnetd/dchannel.d b/source/dnetd/dchannel.d index 394c275..b44d564 100644 --- a/source/dnetd/dchannel.d +++ b/source/dnetd/dchannel.d @@ -31,6 +31,8 @@ public class DChannel { /* Initialize the lock */ memberLock = new Mutex(); + + this.name = name; } public string getName() @@ -50,9 +52,12 @@ public class DChannel * TODO: Error handling if the calling DConnection fails midway * and doesn't unlock it */ + writeln(this); /* Add the client */ members ~= client; + import std.stdio; + writeln(members); /* Unlock the members list */ memberLock.unlock(); diff --git a/source/dnetd/dconnection.d b/source/dnetd/dconnection.d index 5cac824..25a38f8 100644 --- a/source/dnetd/dconnection.d +++ b/source/dnetd/dconnection.d @@ -18,6 +18,7 @@ import core.sync.mutex : Mutex; import dnetd.dserver : DServer; import std.string : split; import dnetd.dchannel : DChannel; +import std.conv : to; public class DConnection : Thread { @@ -226,6 +227,8 @@ public class DConnection : Thread { /* TODO: Thread safety for name choice */ channel = new DChannel(channelName); + + server.addChannel(this, channel); } /* Join the channel */ @@ -370,7 +373,8 @@ public class DConnection : Thread } else { - + byte[] reply = [false]; + writeSocket(tag, reply); } } } @@ -390,4 +394,20 @@ public class DConnection : Thread { 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; + } }