Skip to content

Instantly share code, notes, and snippets.

@adam-stokes
Created February 12, 2014 00:41
Show Gist options
  • Save adam-stokes/8947591 to your computer and use it in GitHub Desktop.
Save adam-stokes/8947591 to your computer and use it in GitHub Desktop.
connect to websocket
#!/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;
@adam-stokes
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment