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!


In reply to Mojolicious: keeping track of connections with forking by Rodster001

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.