1

I have a websocket server running to implement 'lobbies' which people can join and everyone has live feedback of who is in it and what they are doing.

I need to fetch data from third party servers using cURL inside the server instances. When certain data is found I push notifications to everyone in the lobby.

This data can be found at any time so I want to check every 10-20 seconds if new data is available.

How do you implement an async while loop in PHP?

battlenub
  • 187
  • 1
  • 14
  • In general: You don't. The question here is also: Why does it have to be async? Couldn't you just handle it in your logic and add a check so the checking for whatever your cURL does only happens every 10-20 seconds? Otherwise, if you really feel you need to use Threading, [see this answer](http://stackoverflow.com/questions/70855/how-can-one-use-multi-threading-in-php-applications). – ArSeN Dec 29 '15 at 14:31

1 Answers1

0

ReactPHP provides the functionality you need. You can use it as your server or check their sources to implement similar functionality on your own.

Ihor Burlachenko
  • 4,689
  • 1
  • 26
  • 25