How to implement event listening in PHP

后端 未结 5 920
天命终不由人
天命终不由人 2020-12-08 12:22

here is my problem: I have a script (let\'s call it comet.php) whic is requsted by an AJAX client script and wait for a change to happen like this:

while(no         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 13:04

    You need a realtime library.

    One example is Ratchet http://socketo.me/

    The part that takes care of the pub sub is discussed at http://socketo.me/docs/wamp

    The limitation here is that PHP also needs to be the one to initiate the mutable data.

    In other words this wont magically let you subscribe to when MySQL is updated. But if you can edit the MySQL-setting code then you can add the publish part there.

提交回复
热议问题