Now runs
This commit is contained in:
parent
e9a5af7863
commit
ed2694bf35
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"listeners" : {
|
||||
"enabled" : [],
|
||||
"enabled" : ["listener1"],
|
||||
"listener1" : {
|
||||
"type" : "ipv4",
|
||||
"domain" : "10.0.0.9:2222",
|
||||
|
|
|
@ -7,6 +7,7 @@ import std.json : JSONValue, parseJSON;
|
|||
import std.conv : to;
|
||||
import server.listener : ButterflyListener;
|
||||
import server.listeners;
|
||||
import std.string : cmp;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -47,9 +48,12 @@ private ButterflyListener[] constructListeners(JSONValue listenersBlock)
|
|||
{
|
||||
writeln("Constructing listener \"" ~ listener ~ "\" ...");
|
||||
|
||||
if(cmp(listenersBlock[listener]["type"].str(), "ipv4") == 0)
|
||||
{
|
||||
listeners ~= new IPv4Listener(listener, listenersBlock[listener]);
|
||||
}
|
||||
|
||||
|
||||
writeln("Listener \"" ~ listener ~ "\"constructed");
|
||||
writeln("Listener \"" ~ listener ~ "\" constructed");
|
||||
}
|
||||
|
||||
return listeners;
|
||||
|
|
|
@ -2,20 +2,22 @@ module server.listeners;
|
|||
|
||||
import core.thread : Thread;
|
||||
import server.listener : ButterflyListener;
|
||||
import std.socket : Socket, Address, SocketType, ProtocolType;
|
||||
import std.socket : Socket, Address, SocketType, ProtocolType, parseAddress;
|
||||
import std.json : JSONValue;
|
||||
import client.client;
|
||||
import std.conv : to;
|
||||
|
||||
public class IPv4Listener : ButterflyListener
|
||||
{
|
||||
|
||||
private Socket serverSocket;
|
||||
|
||||
this(string name, string domain, JSONValue config)
|
||||
this(string name, JSONValue config)
|
||||
{
|
||||
super(name, domain, config);
|
||||
super(name, config["domain"].str(), config);
|
||||
|
||||
Address bindAddress = parseAddress(config["address"].str(), to!(ushort)(config["port"].str()));
|
||||
|
||||
Address bindAddress;
|
||||
/**
|
||||
* Instantiate a new Socket for the given Address
|
||||
* `bindAddress` of which it will bind to.
|
||||
|
|
Loading…
Reference in New Issue