Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use v6;
- use Cro;
- use Cro::TLS;
- use Cro::TCP;
- class Echo does Cro::Transform {
- method consumes { Cro::TCP::Message }
- method produces { Cro::TCP::Message }
- method transformer(Supply $messages --> Supply) {
- supply {
- whenever $messages -> $m {
- emit Cro::TCP::Message.new(
- :data($m.data),
- );
- }
- }
- }
- }
- my Cro::Service $service = Cro.compose: Cro::TLS::Listener.new(:port(8000), :host("localhost")), Echo;
- $service.start;
- react {
- whenever signal(SIGINT) { $service.stop; done }
- }
Add Comment
Please, Sign In to add comment