Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub connect_websock {
- $ua->websocket('ws://localhost:3000/path' => sub {
- my ($ua, $tx) = @_;
- if (my $err = $tx->error) {
- say "Error: $err";
- Mojo::IOLoop->timer(5 => \&connect_websock);
- return
- }
- $tx->on(message => sub {
- my ($tx, $msg) = @_;
- say $msg;
- });
- $tx->on(finish => sub {
- Mojo::IOLoop->timer(5 => \&connect_websock);
- }
- });
- }
- connect_websock();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement