Dancer2::Plugin::WebSocket::Group
version 0.1.2
websocket_on_message sub { my( $conn, $message ) = @_; if ( $message eq 'tell to everybody' ) { $conn->to( '* ' )->send( "HEY, Y'ALL!" ); } };
Those objects are generated via the to method of the Dancer2::Plugin::WebSocket::Connection objects, and allow to easily send to groups of connections.
to
In addition to any channels one might fancy creating, each connection also has a private channel that is associated to its numerical id, and a global channel * also exist to send messages to all connections.
*
Send the message to all connections of the group.
$conn->to( 'players' )->send( "Hi!" );
Send the message to all connections of the group, except the original connection.
websocket_on_message sub { my( $conn, $msg ) = @_; if ( $msg eq ='resign' ) { $conn->broadcast( "player ", $conn->idm " resigned" ); } }
Yanick Champoux <yanick@cpan.org>
This software is copyright (c) 2019, 2017 by Yanick Champoux.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install Dancer2::Plugin::WebSocket, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer2::Plugin::WebSocket
CPAN shell
perl -MCPAN -e shell install Dancer2::Plugin::WebSocket
For more information on module installation, please visit the detailed CPAN module installation guide.