-
-
11 Oct 2018 17:57:03 UTC
- Distribution: Net-Async-WebSocket
- Module version: 0.13
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (8)
- Testers (2805 / 33 / 19)
- Kwalitee
Bus factor: 1- 85.17% Coverage
- License: perl_5
- Perl: v5.10.0
- Activity
24 month- Tools
- Download (17.85KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
NAME
Net::Async::WebSocket::Client
- connect to a WebSocket server usingIO::Async
SYNOPSIS
use IO::Async::Loop; use Net::Async::WebSocket::Client; my $client = Net::Async::WebSocket::Client->new( on_text_frame => sub { my ( $self, $frame ) = @_; print $frame; }, ); my $loop = IO::Async::Loop->new; $loop->add( $client ); $client->connect( url => "ws://$HOST:$PORT/", )->then( sub { $client->send_text_frame( "Hello, world!\n" ); })->get; $loop->run;
DESCRIPTION
This subclass of Net::Async::WebSocket::Protocol connects to a WebSocket server to establish a WebSocket connection for passing frames.
METHODS
The following methods documented with a trailing call to
->get
return Future instances.connect
$self->connect( %params )->get
Connect to a WebSocket server. Takes the following named parameters:
- url => STRING
-
URL to provide to WebSocket handshake. This is also used to infer the host and service name (port number) if not otherwise supplied.
- req => Protocol::WebSocket::Request
-
Optional. If provided, gives the Protocol::WebSocket::Request instance used for performing the handshake.
The returned Future returns the client instance itself, making it useful in chaining constructors.
connect (void)
$self->connect( %params )
When not returning a
Future
, the following additional parameters provide continuations:connect_handle
$client->connect_handle( $handle, %params )->get
Sets the read and write handles to the IO reference given, then performs the initial handshake using the parameters given. These are as for
connect
.AUTHOR
Paul Evans <leonerd@leonerd.org.uk>
Module Install Instructions
To install Net::Async::WebSocket, copy and paste the appropriate command in to your terminal.
cpanm Net::Async::WebSocket
perl -MCPAN -e shell install Net::Async::WebSocket
For more information on module installation, please visit the detailed CPAN module installation guide.