I've not used AnyEvent::WebSocket::Server before, but a brief review of the documentation suggests that you should be able to add your connections to a structure when you create them and remove them when the connection closes, something like this:
. . . # My box o' global connections my @cnx; . . . $server->establish($fh)->cb( sub { my $connection = eval { shift->recv }; # Add new connection to the box push @cnx, $connection; # Remove connection when it closes $connection->on(finish => sub { @cnx = grep { $_ ne $connection } @cnx; } . . . } ); . . . sub send_global_message { my $msg = shift; for my $c (@cnx) { $c->send($msg); } }
Note: standard warranty applies--Untested, if broken you can keep both pieces, can cause hair loss, impotence, edema, etc.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
In reply to Re: AnyEvent::WebSocket::Server get all connections
by roboticus
in thread AnyEvent::WebSocket::Server get all connections
by Black Vagrant
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |