Reputation: 32331
I am implementing a shopping cart website , which can be used by multiple vendors at a time simultaneously .
I have a requirement as When a new order comes in, the Order status should be in Yellow color (New Order ) and if it is accepted by any of the Vendor it should turn to Blue Color (Processed state)
I am confused at this scenario :
Assume that 4 vendors are watching the Orders simultaneously , a new order has come in which initially shown in yellow color and one of the vendor accepted that , how can i change the color of that Order to Blue Color to the remaining 3 Vendors ??
Any suggestions as how to implement this type of requirement ??
Upvotes: 0
Views: 56
Reputation: 671
You can change the color to blue by doing the following:
Once the request has come in, wrap the request in a
Target the "accepted" id with a css rule that sets the color to blue. When the page refreshes on the other vendors it will be blue.
Upvotes: -1
Reputation: 61
depending on your application there could be a lot of solution but here is one that worked for me:
have the 4 vendors connected to your application server via websocket.
when one accept the order it notifies the server which does the right processing and then send back a notification to everyone connected on the page, which would eventually tell them that this specific order has been approved by Mr. X and should now be displayed Blue color
you could on the other hand work with ajax polling and ask the database every x seconds (x beeing small) if the order has been processed
but once again it really depends on your installation
Upvotes: 0
Reputation: 1387
You will need a server-side solution for this, because you will need a persistent connection to remain open with all clients.
What solution you use will depend on your server setup, but this stack overflow post is a good introduction: What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?
Upvotes: 2
Reputation:
You need either to have every client poll (continuously ajax requesting) the server for status changes, or have them connected to the server trough a socket and have the server push status change events.
Polling is more resource intensive but much easier to implement, while sockets go easy on server load, but requires deeper understanding and arguably more programming.
Upvotes: 0