Mojo::IOLoop::Stream::WebSocketClient - Non-blocking I/O WebSocket client stream
use Mojo::IOLoop::Stream::WebSocketClient; use Mojo::Transaction::WebSocket; # Create transaction my $ws = Mojo::Transaction::WebSocket->new; $ws->on(message => sub { my ($ws, $msg) = @_; say "Message: $msg"; }); # Create stream and process transaction with it my $stream = Mojo::IOLoop::Stream::WebSocketClient->new($handle); $stream->process($ws); # Start reactor if necessary $stream->reactor->start unless $stream->reactor->is_running;
Mojo::IOLoop::Stream::WebSocketClient is a container for I/O streams used by Mojo::IOLoop to support the WebSocket protocol client-side.
Mojo::IOLoop::Stream::WebSocketClient inherits all events from Mojo::IOLoop::Stream::HTTPClient.
Mojo::IOLoop::Stream::WebSocketClient inherits all attributes from Mojo::IOLoop::Stream::HTTPClient.
Mojo::IOLoop::Stream::WebSocketClient inherits all methods from Mojo::IOLoop::Stream::HTTPClient and implements the following new ones.
$stream->process(Mojo::Transaction::WebSocket->new);
Process a Mojo::Transaction::WebSocket object.
Mojolicious, Mojolicious::Guides, http://mojolicious.org.
To install Mojolicious, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious
CPAN shell
perl -MCPAN -e shell install Mojolicious
For more information on module installation, please visit the detailed CPAN module installation guide.