Answer the question
In order to leave comments, you need to log in
Replacing long polling to track database changes?
There is a small server, on it something like a Dutch auction is spinning, in which the cost of a lot changes every few minutes. The price change was implemented by the database.
Now, to display the current cost, every second access to the server is used. It became interesting whether it is possible to implement this using sockets, instead of constantly monitoring changes?
There is also a chat, it is implemented using sockets and the module https://github.com/walkor/phpsocket.io
But everything is clear here, because there is a trigger to call handlers. And how to implement a pure listener and update on the client - I don’t know
Answer the question
In order to leave comments, you need to log in
What the hell do you recommend to a person to remove the tonsils through the ass. Which websocket in mysql are you what? What triggers.
The backend is the only one who should change the critical information in the database, so let him send the necessary information to the clients in the websocket.
The websocket server is five lines in php, a couple of lines in the client, and a few tweaks to set up an autostart service. If the websocket is already there, then nothing needs to be done. You come up with the type of message that the server will send over this web socket to clients, clients should not display it, but instead request information using the old method that you now update data every second. ALL.
When a customer gives a price to a product, the backend looks at which customers are buying it and sends them a message. You may have to keep an array in memory - which client in the database = websocket client, but with a probability of 99.(9)% this has already been done (at least display the name and authorization)
Well, you can do without replacing with websockets. You yourself wrote:
in which the cost of the lot changes every few minutes
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question