简体   繁体   中英

Server Sent Event to show a navigation button

I have a web point of sale, and I have a few buttons hidden for certain functions. I need to be able to have a manager click "Enable" in the admin panel and it immediately shows in the POS.

I have been looking in to the Server Sent Events technology and it seems to be what I need, but I am just not sure how to implement it.

In very general terms:

  1. Your client application is hooked to your ServerSent handler
  2. Your ServerSent handler is reading from a database or other storage mechanism every 1,2,5, 10 seconds (whatever is and acceptable lag between requests to simulate "immediate and live" event), so polling for your adminstration configuration update
  3. Adminstrator clicks enable from his console which updates status in DB (client specific, that is up to your design)
  4. ServerSent handler on its next polling picks up on the status change and writes an event message to the client (event arbitrarily named, again your design)
  5. Assuming your client-side ServerSent code has previously registered for this event, the event is handled and you enable those buttons

Hope this helps..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM