Net::Async::WebSocket::JSON::Client - connect to a WebSocket server using JSON and IO::Async
Net::Async::WebSocket::JSON::Client
IO::Async
use IO::Async::Loop; use Net::Async::WebSocket::JSON::Client; use Data::Dump; my $client = Net::Async::WebSocket::JSON::Client->new( on_json => sub { my ( $self, $data ) = @_; print Data::Dump::pp( $data ); }, ); my $loop = IO::Async::Loop->new; $loop->add( $client ); $client->connect( url => "ws://$HOST:$PORT/", )->then( sub { $client->send_json( { message => "Hello, world!\n" } ); })->get; $loop->run;
This subclass of Net::Async::WebSocket::Client provides conveniences for using JSON-encoded data sent over text frames.
It should be used identically to Net::Async::WebSocket::Client, except that it has the new send_json method and on_json event defined by Net::Async::WebSocket::JSON::Protocol.
Net::Async::WebSocket::Client
send_json
on_json
Paul Evans <leonerd@leonerd.org.uk>
To install Net::Async::WebSocket::JSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Async::WebSocket::JSON
CPAN shell
perl -MCPAN -e shell install Net::Async::WebSocket::JSON
For more information on module installation, please visit the detailed CPAN module installation guide.