Guest User

Untitled

a guest
Oct 16th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. use v6;
  2. use Cro;
  3. use Cro::TLS;
  4. use Cro::TCP;
  5.  
  6. class Echo does Cro::Transform {
  7. method consumes { Cro::TCP::Message }
  8. method produces { Cro::TCP::Message }
  9. method transformer(Supply $messages --> Supply) {
  10. supply {
  11. whenever $messages -> $m {
  12. emit Cro::TCP::Message.new(
  13. :data($m.data),
  14. );
  15. }
  16. }
  17. }
  18. }
  19.  
  20. my Cro::Service $service = Cro.compose: Cro::TLS::Listener.new(:port(8000), :host("localhost")), Echo;
  21.  
  22. $service.start;
  23.  
  24. react {
  25. whenever signal(SIGINT) { $service.stop; done }
  26. }
Add Comment
Please, Sign In to add comment