I'm creating a script that uses a websocket. It will constantly process many frames all the time. My script will collect all the data from those frames, and periodically perform some calculations on that data it maintains. I had it working so my calculations would run every second, and my script seemed to keep up with the data collection ok. However, that doesn't seem like the best method.

I think ideally, my calculations would run every time all frames are collected and the websocket is idle, even if just for a few milliseconds. That way I know my calculations are using the most current data received, and my 1 second timer won't be blocking the websocket from reading the frames it has already received. Then I would also know my calculations are run as frequently as possible rather than a fixed 1 second timer.

I can't seem to find a websocket module that has an idle event. It doesn't even need to use events. Even something with a function that will process all received frames when called and return when completed should work fine. Then I could just put that in a loop with my calculations. I can't seem to find anything like that though. Thanks monks in advance for any help.


In reply to WebSocket idle by chris212

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.