NAME
Mojo::IOLoop::Stream::WebSocketServer - Non-blocking I/O WebSocket server stream
SYNOPSIS
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;
DESCRIPTION
Mojo::IOLoop::Stream::WebSocketServer is a container for I/O streams used by Mojo::IOLoop to support the WebSocket protocol server-side.
EVENTS
Mojo::IOLoop::Stream::WEBSocketServer inherits all events from Mojo::IOLoop::Stream::HTTPServer.
ATTRIBUTES
Mojo::IOLoop::Stream::WebSocketServer inherits all attributes from Mojo::IOLoop::Stream::HTTPServer.
METHODS
Mojo::IOLoop::Stream::WebSocketServer inherits all methods from Mojo::IOLoop::Stream::HTTPServer and implements the following new ones.
process
$stream->process(Mojo::Transaction::WebSocket->new);
Process a Mojo::Transaction::WebSocket object.