Hi Monks,
I have a mojolicious project which I developed using the morbo development web server. Now I am ready to deploy using hypnotoad but I have run into an issue.
I am keeping track of client "session" connections, like this:
my $clients = {};
websocket '*' => sub {
my $c = shift;
my $socket_id = $c->tx->connection;
$clients->{$socket_id} = $c->tx;
};
And then sending messages to each client of that "session":
foreach my $socket_id (keys %{ $clients }) {
$clients->{$socket_id}->send({ json => { message => "hi" } });
}
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.
And honestly I am not 100% sure if I have fully understood the problem yet. Any help would be greatly appreciated!