The PHP WebSocket framework Demo has been run (workerman-& amp; gt; web-msg-sender). Now, a problem occurs, that is, how to push information like a specified page. For example, each user's home page, each user's favorite list page, and some public commodity list pages, the prices of these pages are all... PHP WebSocket framework Demo has been run (workerman-> web-msg-sender)
The problem is how to push information like a specified page.
For example, each user's homepage, each user's favorite list page, and somePublicThe prices of these pages are updated in real time.
Currently, I think of the following methods: 1. When the product price is updated, the corresponding product information is retrieved from the table. 2. Public pages: home pages and product list pages; the push URL is specified in the background to push the updated product ID and price. After obtaining the result, JS checks whether the current page has a pushed product ID. If yes, the price will be updated? 3. Do personal pages, such as favorite pages, work like this?
Reply content:
PHP WebSocket framework Demo has been run (workerman-> web-msg-sender)
The problem is how to push information like a specified page.
For example, each user's homepage, each user's favorite list page, and somePublicThe prices of these pages are updated in real time.
Currently, I think of the following methods: 1. When the product price is updated, the corresponding product information is retrieved from the table. 2. Public pages: home pages and product list pages; the push URL is specified in the background to push the updated product ID and price. After obtaining the result, JS checks whether the current page has a pushed product ID. If yes, the price will be updated? 3. Do personal pages, such as favorite pages, work like this?
This function should not be available. Generally, the browser uses the socket. io connection of js to obtain the push content. It is determined by the js of the browser. For example, the server pushes {action: update; type: product; details: [{product_id: 1, price: 5.30}]}, the browser can use if ($ ('# product-list '). length) updateProducts (response.
Supplement: The above is a bit confusing. Simply put, it does not need to be processed, because since a visitor is not on a specific page, it naturally does not need to process the push. If it is on a specific page, then there must be specific methods to deal with it, right?