Dancer2...t::Group(3)
πΈ NAME
Okay so, from the User Contributed Perl Documentation, the module is Dancer2::Plugin::WebSocket::Group. That's the NAME section, and yes it ate. π
β¨ VERSION
Version 0.3.1 β that's the vibe check result, and it passed. π¦
π SYNOPSIS
Here's the little code moment, copied exactly:
websocket_on_message sub {
my( $conn, $message ) = @_;
if ( $message eq 'tell to everybody' ) {
$conn->to( '* ' )->send( "HEY, Y'ALL!" );
}
};
π DESC
These objects are generated via the to method of the Dancer2::Plugin::WebSocket::Connection objects, and they let you easily send to groups of connections. Slay. β¨
In addition to any channels one might fancy creating, each connection also has a private channel that is associated to its numerical id, and there's also a global channel * that exists to send messages to all connections. Iconic. π
π«Ά Methods
Two methods, both cute, both useful. Let's go.
send( $message )β sends the message to all connections of the group. Example:
$conn->to( 'players' )->send( "Hi!" );
broadcast( $message )β sends the message to all connections of the group, except the original connection. Example:
websocket_on_message sub {
my( $conn, $msg ) = @_;
if ( $msg eq ='resign' ) {
$conn->broadcast( "player ", $conn->idm " resigned" );
}
}
π AUTHOR
Yanick Champoux <yanick@cpan.org> β yes, that's the author, give him his flowers. π
π COPYRIGHT AND LICENSE
Copyright line, exactly:
This software is copyright (c) 2021, 2019, 2017 by Yanick Champoux.
License line, exactly:
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Free software, bestie β same terms as Perl 5 itself. π«Ά
Okay that's the whole page. Footer vibes: perl v5.42.0, dated 2021-05-31, title Dancer2...t::Group(3). Bye bestie, go send some group messages π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Dancer2-Plugin-WebSocket 0.3.1-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms