Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: websocket infinit loop

by Anonymous Monk
on Dec 13, 2016 at 02:09 UTC ( [id://1177680]=note: print w/replies, xml ) Need Help??


in reply to websocket infinit loop

The infinite loop examples that I have found, are not suitable in this case because I need to use an infinite loop that can check for incoming data on both connections.

Look at the Mojo examples, the entire premise, is there is one loop, when an event happens, a subroutine is called ( a call back), the callback does the checking for things its concerned about ( one connection, another connection, something else )

All you do is "register" subroutines to respond to events, an event is anything, from connecting to a socket, to getting a message, to a timer expiring ...

Example Re^4: real-time output from Mojolicious WebSockets?

All these things can be part of the same program, as long as you're not blocking for long, it all just keep running
https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Non-blocking
https://metacpan.org/pod/Mojolicious::Guides::Cookbook#WebSockets
https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Synchronizing-non-blocking-operations

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1177680]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-24 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found