How to push javascript-WebSocket to a specified page

Source: Internet
Author: User
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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.