server
#!/usr/bin/env raku
unlink "/run/user/1000/sock";
my $socket = IO::Socket::Async.listen-path("/run/user/1000/sock");
react {
my $timerSupplier = Supplier.new;
whenever $timerSupplier.Supply.migrate {
say "3 second interval: ", $_;
}
$timerSupplier.emit(Supply.interval(3));
whenever $socket -> $conn {
$timerSupplier.emit(Supply.interval(3));
say "\"", $_.Supply.lines.Channel.receive, "\"";
$conn.close;
}
}
client
#!/usr/bin/env raku
my $sock = IO::Socket::Async.connect-path("/run/user/1000/sock").result;
await $sock.print("ok\n");
If I execute server and then client, I get the following exception.
Unhandled exception in code scheduled on thread 8
Can only cancel an AsyncTask handle
in block at ./server line 16
Can anyone tell me what is the problem?
Replacing
whenever $socket -> $conn {
$timerSupplier.emit(Supply.interval(3));
say "\"", $_.Supply.lines.Channel.receive, "\"";
$conn.close;
}
with
whenever $socket -> $conn {
$timerSupplier.emit(Supply.interval(3));
say "\"", $conn.Supply.lines.Channel.receive, "\"";
$conn.close;
}
fixed the error. It seems if a block has a named parameter, the topic variable stops working.