Created
February 12, 2014 00:41
-
-
Save adam-stokes/8947591 to your computer and use it in GitHub Desktop.
connect to websocket
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
#!/usr/bin/env perl | |
use Mojo::UserAgent; | |
my $endpoint = 'wss://10.0.3.1:17070/'; | |
my $ua = Mojo::UserAgent->new; | |
$ua->websocket( | |
$endpoint => sub { | |
my $tx = pop; | |
$tx->on(finish => sub { Mojo::IOLoop->stop }); | |
$tx->on( | |
json => sub { | |
my ($tx, $msg) = @_; | |
say $msg; | |
} | |
); | |
$tx->send(json => {"RequestId" => 1, "Type" => "Login"}); | |
} | |
); | |
Mojo::IOLoop->start unless Mojo::IOLoop->is_running; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Mojo::Reactor::Poll: Read failed: Mojo::UserAgent: Event "read" failed: Can't locate object method "send" via package "Mojo::Transaction::HTTP" at ./eg/envinfo.pl line 19.