Added `toString`s for all the listeners.

This commit is contained in:
Tristan B. Kildaire 2020-05-09 15:19:57 +02:00
parent 9f565e9c09
commit 9c853b22c3
3 changed files with 25 additions and 1 deletions

View File

@ -27,6 +27,9 @@ public class BesterListener : Thread
/* Whether or not the listener is active */
private bool active = true;
/* the address of this listener */
protected Address address;
this(BesterServer besterServer)
{
/* Set the function address to be called as the worker function */
@ -43,6 +46,9 @@ public class BesterListener : Thread
{
/* Set the server socket */
this.serverSocket = serverSocket;
/* Set the address */
address = serverSocket.localAddress();
}
/**

View File

@ -19,6 +19,12 @@ public final class UNIXListener : BesterListener
unixSocket.bind(address);
return unixSocket;
}
override public string toString()
{
string address = "unix://"~super.address.toAddrString();
return address;
}
}
public final class TCP4Listener : BesterListener
@ -35,6 +41,12 @@ public final class TCP4Listener : BesterListener
tcp4Socket.bind(address);
return tcp4Socket;
}
override public string toString()
{
string address = "tcp4://"~super.address.toAddrString();
return address;
}
}
public final class TCP6Listener : BesterListener
@ -51,5 +63,11 @@ public final class TCP6Listener : BesterListener
tcp6Socket.bind(address);
return tcp6Socket;
}
override public string toString()
{
string address = "tcp6://"~super.address.toAddrString();
return address;
}
}

View File

@ -201,7 +201,7 @@ public final class BesterInformerClient : Thread
for(ulong i = 0; i < server.listeners.length; i++)
{
JSONValue listener;
listener["address"] = server.listeners[i].getServerSocket().localAddress().toAddrString();
listener["address"] = server.listeners[i].toString();
listenersBlock["listener"~to!(string)(i)] = listener;
}