My app uses Django Rest Framework for the API. I wanted to add live notifications/status to it.
The flow would be
User loads page then makes a get API request to load data
Websocket connects on page load and subscribes to 'notifications' channel that's in ServerNotifConsumer
User clicks a button which sends a POST request to API that does some db stuff that would return success or failure info. Returns status 202 Accepted immediately then processes command.
Return info via websocket to all subscribed clients
Is there a way from within the DRF viewset action to send anything to the websocket consumer? Or would the best way to go about this be to rewrite the API endpoint to only receive via websocket? (rather not do)
Related
I design a application for a restaurant one of the features is that the user can make an order online and the oreder status is pending until the restaurant cashier or restaurant admin staff convert status by accept or refuse
so i wanna send to client a notification if there is pending orders or something that the admin staff or cashier know that there is an pending order created now without need to update or refresh the client page
so my question is how i make a backend server send to client browser notification without the client need to refresh the page or send request to backend server
i use django rest framework
I hear about websocket and Django channels
Also i hear about SSE
Also i read about client freamwork send requests every n minute to update the page
I need to know what the best approach to implement this and if there is another technology and what is best for server if there is a lot of loading or the application used by millions of users
For example - you can implementig full-state service on nodejs + express + socket.io or asp.net + signalR. Client connecting to your service via websocket if customer open page where there order status. This solution will allow scale only service if connecting many client, also you should think over communication between service and general app on django, for example use rabbit or kafka or other. Also your can use this service for new realtime features
I'm doing this -
Load single page application - an apollo client is initialised with a websocket and http link. This happens when the user is logged out, let's say.
The user then logs in without a page reload. The graphql response now contains the session cookie.
Problem - whilst subsequent http requests include the session cookie the websocket connection does not.
How do people solve this problem?
I'm guessing either make all communication with the server via websockets, or, create a new apollo client upon successful sign in and use this for subscriptions.
This is for a chat app. I'm using http and websockets at the moment.
I have android app on which my django server is sending some push notifications using firebase cloud messaging. As soon as client received the notifications, it makes a GET request to my API written using Tastypie.
I want to somehow store this GET request in my Log table so that I can ensure that my android app is working fine and make right requests on receiving notifications from server.
On one of the answers, I read that it can be achieved by overriding the dispatch function for Model Resource in tastypie. Could this logging be achieved without overriding the dispatch because it can potentially increase the response time.
We have an application where in we need to notify a URL whenever a new user is created in the Google Apps Domain. The notifying url is https://projectId.appspot.com/userWatcher. Have verified the domain in the app engine console as https://projectId.appspot.com even then unuable to receive the push notification messages to the notifying URL. Kindly help me out
To use push notification make sure you do this things:
Register the domain of your receiving URL.
For example, if you plan to use https://example.com/notifications as your receiving URL, you need to register https://example.com.
Set up your receiving URL, or "Webhook" callback receiver.
This is an HTTPS server that handles the API notification messages that are triggered when a resource changes.
Set up a notification channel for each resource endpoint you want to watch.
A channel specifies routing information for notification messages. As part of the channel setup, you identify the specific URL where you want to receive notifications. Whenever a channel's resource changes, the Reports API sends a notification message as a POST request to that URL.
For more information check this page.
I have build an eCommerce website using emberjs with ember-data-1.8.0.On Api side i am using Hapijs.
I have integrated Payu payment gateway with it,but i am not able to handle response send by payu.After payment payu send a post response to given route of ember, but How will i handle this response and will get all payload so i can send request to my hapi server.
i have no clue how to do it, if there is some doc or example of integrating payment gateway and emberjs, please mention it also.
Thanks
Ember is a client side framework, Payu will not be able to send a "post" request to ember it may perform it on your Hapijs backend however. Then you have many options to check events on your backend from your frontend for example through sockets or via a setInterval which queries a given page every N seconds.