Closed marmotz closed 6 years ago
Hello :)
Can you bit more specific? Did you want a Hoa\Websocket\Server
send indefinitely message to client within a interval?
Well... I don't know how to be more specific.
My need is to check a local variable and resend message if there was no response from client. So I want to check this variable every "tick" to check message sent one minute ago and resend it. But this is so specif to my app.
My need is a global need: to do an action every x seconds and not on a given event (message, ping, etc...)
For the moment, I use a workaround. I listen every events (binary-message, close, error, message, open and ping) and I hope there are enough events to simulate what I want...
I dunno if this is possible right now, because the run
method will be blocked by stream_select
It mean, even with concurrent tasks generator that should probably don't work with another loop.
The easier solution in your case is to spawn a client for this purpose. You can have a local daemon or a cronjob that will send message to server with specific key that make the job you want to do.
If you want to hack it, check it out nikita work: https://nikic.github.io/2012/12/22/Cooperative-multitasking-using-coroutines-in-PHP.html
I think my workaround will do the job :-/
The next version of hoa/websocket
will rely on hoa/future
and a new version of hoa/socket
. It will allow that. Right now, it's not possible. Sorry.
Good news, thanks Hywan :)
Hi everyone,
I want to do a given action every x seconds or ticks.
Is there a way to do that ?