Net::Async::WebSocket::JSON::Server - server WebSocket clients using JSON and IO::Async
Net::Async::WebSocket::JSON::Server
IO::Async
use IO::Async::Loop; use Net::Async::WebSocket::JSON::Server; my $server = Net::Async::WebSocket::JSON::Server->new( on_client => sub { my ( undef, $client ) = @_; $client->configure( on_json => sub { my ( $self, $frame ) = @_; $self->send_json( $frame ); }, ); } ); my $loop = IO::Async::Loop->new; $loop->add( $server ); $server->listen( service => 3000, )->get; $loop->run;
This subclass of Net::Async::WebSocket::Server provides conveniences for using JSON-encoded data sent over text frames.
It should be used identically to Net::Async::WebSocket::Server, except that connected client instances will be instances of Net::Async::WebSocket::JSON::Protocol, and have the new send_json method and on_json event available.
Net::Async::WebSocket::Server
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.