Thanks. Just placing code from the very first link in OP to a separate thread (e.g. with IO::Async::Routine) gave me nothing, because Mojo::IOLoop-> one_tick blocks again, and Routine won't accept commands from 'main' loop. So, a Mojo::IOLoop::Stream (?) must be added to Mojo's loop for communication. For which I need some time to figure it all out. Or, otherwise, ugly timers, be it separate thread or not.

OTOH, staying within IO::Async (Net::Async) namespaces, the Net::Async::HTTP::Server and Net::Async::WebSocket::Server solved, partly, what this all was about, with a single event loop. Just partly.

Closing browser (hence Websocket connection) leads to instantaneous on_close and "WebSocket closed with status 1001" using simple Mojolicious application. But in "pure" IO:Async (Net::Async) app I get on_frame event with WebSocket frame being 2 characters "\x{03}\x{fffd}". What does it mean, how to parse it? Does it have to (and will it) be so low level all the way ahead?

On still another hand, I just wanted to experiment with Mojolicious, use it within existing IO:Async app. Sorry for this rant :)


In reply to Re^2: "Web server embedding" (Mojolicious docs) by vr
in thread "Web server embedding" (Mojolicious docs) by vr

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.