Rodster001 has asked for the wisdom of the Perl Monks concerning the following question:
And then sending messages to each client of that "session":my $clients = {}; websocket '*' => sub { my $c = shift; my $socket_id = $c->tx->connection; $clients->{$socket_id} = $c->tx; };
This works great under morbo. But not so under hypnotoad. I believe it is because hypnotoad forks and the socket ids of child processes are not shared across children. So either one child cannot send messages to another, or I need a different way of identifying/finding sockets of children.foreach my $socket_id (keys %{ $clients }) { $clients->{$socket_id}->send({ json => { message => "hi" } }); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mojolicious: keeping track of connections with forking
by Anonymous Monk on May 15, 2017 at 19:20 UTC | |
by Rodster001 (Pilgrim) on May 15, 2017 at 19:33 UTC | |
by Anonymous Monk on May 16, 2017 at 02:49 UTC | |
by Rodster001 (Pilgrim) on May 16, 2017 at 16:21 UTC | |
by Rodster001 (Pilgrim) on May 16, 2017 at 16:10 UTC |