Mojo::IOLoop::Stream::WebSocketServer - Non-blocking I/O WebSocket server stream
use Mojo::IOLoop::Stream::WebSocketServer; 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::WebSocketServer->new($handle); $stream->process($ws); # Start reactor if necessary $stream->reactor->start unless $stream->reactor->is_running;
Mojo::IOLoop::Stream::WebSocketServer is a container for I/O streams used by Mojo::IOLoop to support the WebSocket protocol server-side.
Mojo::IOLoop::Stream::WEBSocketServer inherits all events from Mojo::IOLoop::Stream::HTTPServer.
Mojo::IOLoop::Stream::WebSocketServer inherits all attributes from Mojo::IOLoop::Stream::HTTPServer.
Mojo::IOLoop::Stream::WebSocketServer inherits all methods from Mojo::IOLoop::Stream::HTTPServer 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.