Added listener construction function (WIP)
This commit is contained in:
parent
0326b61e34
commit
e49f8fa9fd
|
@ -1,5 +1,15 @@
|
|||
{
|
||||
"domain" : "10.0.0.9:2222",
|
||||
"address" : "0.0.0.0",
|
||||
"port" : "6969"
|
||||
"listeners" : {
|
||||
"enabled" : [],
|
||||
"ipv4" : {
|
||||
"domain" : "10.0.0.9:2222",
|
||||
"address" : "0.0.0.0",
|
||||
"port" : "6969"
|
||||
},
|
||||
"ipv6" : {
|
||||
"domain" : "10.0.0.9:2222",
|
||||
"address" : "::",
|
||||
"port" : "6969"
|
||||
}
|
||||
}
|
||||
}
|
19
source/app.d
19
source/app.d
|
@ -5,6 +5,7 @@ import std.socket : Address, parseAddress;
|
|||
import std.file;
|
||||
import std.json : JSONValue, parseJSON;
|
||||
import std.conv : to;
|
||||
import server.listener : ButterflyListener;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -21,7 +22,23 @@ void main()
|
|||
|
||||
config = parseJSON(cast(string)bytes);
|
||||
|
||||
/* Construct the listeners form the config file */
|
||||
ButterflyListener[] listeners = constructListeners(config["listeners"]);
|
||||
|
||||
/* Start the server */
|
||||
Address address = parseAddress(config["address"].str(), to!(ushort)(config["port"].str()));
|
||||
ButterflyServer server = new ButterflyServer(address, config["domain"].str());
|
||||
ButterflyServer server = new ButterflyServer(listeners, config["domain"].str());
|
||||
}
|
||||
|
||||
private ButterflyListener[] constructListeners(JSONValue listenersBlock)
|
||||
{
|
||||
ButterflyListener[] listeners;
|
||||
|
||||
string[] enabledListeners;
|
||||
foreach(JSONValue listenerType; listenersBlock["enabled"].array())
|
||||
{
|
||||
enabledListeners ~= listenerType.str();
|
||||
}
|
||||
|
||||
return listeners;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue