Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl6
- use v6.c;
- class MockServer {
- has @.events is rw;
- method start-up() {
- say 'server starting';
- react {
- whenever IO::Socket::Async.listen('127.0.0.1', 3005) -> $conn {
- say 'all up in my server';
- whenever $conn.Supply.lines -> $line {
- # send Initial message
- $conn.print("Hey there my dude.\r\n\r\n");
- }
- }
- }
- say 'fuck it im done';
- }
- }
- my MockServer $mock-server = MockServer.new();
- Promise.in(1).then({
- $mock-server.start-up();
- });
- await IO::Socket::Async.connect('127.0.0.1', 3005).then( -> $promise {
- given $promise.result {
- .print("Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n");
- react {
- whenever .Supply() -> $v {
- $v.print;
- done;
- }
- }
- .close;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement