mardi 21 juillet 2020

Laravel: How to repeat a function until something happens?

I am building a web service for an android application. When some thing happens in server, I broadcast a message to a device via Laravel-Echo and Socket.io. Sometimes, something may prevent the device from listening to the message for a while (for example interrupting internet connection), So in such cases, I have to broadcast again. In fact, If the device doesn't get the message I will have to broadcast again for several times (say 10). To handle this, If the device get the message it will post to a function and in that function, I store a variable in the Redis which represents that the device listened successfully.

The problem is, I don't know how to implement this cycle of Redis check. After the first broadcast, I need to check the Redis every 30 seconds for 7 times to see if the variable exists. I don't know to implement this by events, queue or tasks.

Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire