NAME

Net::Async::WebSocket::JSON::Client - connect to a WebSocket server using JSON and IO::Async

SYNOPSIS

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;

DESCRIPTION

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.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>