blob: 53f4ba9e9ede84c771a16b3fb90442054ee91d15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
use v6.d; unit class MaildirIndexer::Server; use MaildirIndexer::Parser; use MaildirIndexer::Store; has $.port = 9000; has MaildirIndexer::Store $.store is required; method serve() { my $listener = IO::Socket::Async.listen( '127.0.0.1', 9000, :enc<utf8-c8>, ); react { whenever signal(SIGINT) { exit } whenever signal(SIGHUP) { $.store.dump(); } whenever $listener -> $conn { LEAVE { $conn.close } with parse-email($conn) -> $email { with $.store.mailbox-for-email($email) -> $mailbox { await $conn.print("$mailbox\x0d\x0a"); } } } } }
|