salty-ircd/source/ircd/app.d

38 lines
607 B
D
Raw Normal View History

2017-03-11 06:14:48 +01:00
module ircd.app;
import std.stdio;
import std.algorithm;
2017-03-11 06:31:36 +01:00
import std.range;
2017-03-11 06:14:48 +01:00
import core.time;
2017-03-11 16:45:05 +01:00
import vibe.core.core;
2017-03-11 06:14:48 +01:00
import ircd.message;
import ircd.connection;
shared static this()
{
Connection[] connections = [];
2017-03-11 06:31:36 +01:00
runTask(delegate()
{
while(true)
{
foreach(connection; connections)
{
connection.send(Message(null, "PING", [connection.nick]));
}
sleep(10.seconds);
}
});
2017-03-11 06:14:48 +01:00
listenTCP(6667, delegate(TCPConnection connection)
{
auto c = new Connection(connection);
connections ~= c;
c.handle();
connections = connections.filter!(a => a != c).array;
},"127.0.0.1");
}