Created
October 16, 2017 12:50
-
-
Save ufobat/b165a66b1e3ab3228d1d0622fda20c9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment