Scroll to navigation

Dancer2::Plugin::WebSocket::Connection(3) User Contributed Perl Documentation Dancer2::Plugin::WebSocket::Connection(3)

NAME

Dancer2::Plugin::WebSocket::Connection - Role tying Plack::App::WebSocket::Connection with the Dancer serializer

VERSION

version 0.3.1

DESCRIPTION

The connection objects used by Dancer2::Plugin::WebSocket are Plack::App::WebSocket::Connection objects augmented with this role.

Attributes

Serializer object used to serialize/deserialize messages. If it's not "undef", all messages that are not AnyEvent::WebSocket::Message objects are assumed to be JSON and will be deserialized before being passed to the handlers, and will be serialized after being give to "send".
A numerical value that is the id of the connection.

Methods

Set the channels this connection belongs to. In addition to the @channels provided, the connection is always associated to its id channel (which is always numerical) as well as the global channel "*".
Add @channels to the list of channels the connection belongs to.
Returns "true" if the connection belongs to at least one of the given @channels.
Returns a Dancer2::Plugin::WebSocket::Group that will emit messages to all connections belonging to the given @channels.

    $conn->to( 'players' )->send( "game about to begin" );
    

AUTHOR

Yanick Champoux <yanick@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021, 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.

2021-05-31 perl v5.38.2