Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending notification to the user on database change

I am building a cafeteria management system in which there are two types of users;customres & counter owners.

For each dish offered in cafeteria, there is aunique dish.id associated to it.

Till now, I have dome something like student sends a POST request with dish,id and counter number to a URL which updates the "orders table'(which has PK as id). When the dish is prepared, the counter owner presses "Prepeared" button.

At this point, I want the customer whose order is next to what is prepared to get notified that "Your order preparation is in progress."

How should I do it? One way is to simply make a view which has its argument as customer.id & status and it replies with True or Flase. I can simply poll the URL and provide the notification if I recieve True.

But, I feel like polling is not a better approach as there will be so many customers logged in and each will poll to the server which is not acceptible. Any better way?

like image 976
Abhijeet Rastogi Avatar asked Apr 02 '11 04:04

Abhijeet Rastogi


People also ask

How does firebase notify the app about changes in the data?

You create a firebase cloud function that is run when certain areas of the database are changed. 3. This function has a look at what has changed; compares it to the data created in (1) and sends a notification to each device token that requires it.

What is push notification how it works?

A push notification is a message that pops up on a mobile device, such as a sports score, an invitation to a flash sale or a coupon for downloading. App publishers can send them at any time, since users don't have to be in the app or using their devices to receive them.


2 Answers

It really depends what you really need.

If notification can be sent ad part of user activity, simply add a user message, and it will be displayed whenever user do an action on the page. django.contrib.messages plus few lines in your main html template will do it.

But if you want the notification to be interactive - you can use one of the few PUSH options

Interesting links:

  • wikipedia on reverse ajax
  • comet

From the servers side, there are few options available, the simplest is Green Unicorn. Using it will allow you to have few thousands connections open and managed by only few processes.

like image 170
Jerzyk Avatar answered Oct 18 '22 22:10

Jerzyk


I don;t know if u understood corectly but i think you should use websockets

 http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ 
like image 22
andrei Avatar answered Oct 19 '22 00:10

andrei