Socket.IO - Offline Notification - javascript

I'm building a MERN stack app. I'm trying to implement notification with Socket. IO.(I am a beginner for Socket. IO)
My scenario is like this, it's an e-commerce website. I'm trying to send a notification to the seller if a buyer adds that product to their favorite list.
If the seller is offline, can we save that favorite added notification, and can we indicate that notification using Socket.io after the seller comes online?
(As an example on Facebook we can see liked notifications when we go online.)
For that case should I send that notification details to the backend after that can I save it in my database or is there any feature to save that notification in Socket.io with a connection with the database?
Thanks, any help is appreciated!

Related

Real-time sockets between Android and server

For learning purposes I’m creating an Android app that does the following:
When a person arrives at school, he/she can check a button in the app and he/she is added in real-time to a list (in the server database) of everyone that also checked “at school” button within the app. He/she can also add a message before clicking the button.
The rest of the students then receive a toast in real-time with the person’s name that arrived and it’s message.
I know how to do the Android part, but what is the best way to do the real-time event queries and requests in communication with the server? For example, I send a socket with the persons confirmation, location and message to the server. From the server-side, I supose there’s a nodejs controller that receives the socket and updates the database in sql. Then it sends a socket to every client online and a confirmation to the checked client.
Is this the “professional” way to handle data like this? What is the best (fastest, more secure, standard) way? When I Google how to make this communication I can only find web server client-server communication with Apache, but I’m really looking for a real-time event with an Android app.
I’m not really looking for code but to know and understand technologies and design patterns on how this can be done. And what to search for in order to learn how to do this.

How to make a chat application in react native?

I have build chat UI for my application using react-native-gifted-chat. I have connected the sent messages and received messages with the services. Can anyone help me with the issue of messages not getting updated instantly as the message is received?
Do I need to hit services again and again to refresh the chat message? if yes then how?
Or do I need to implement some kind of push notification? if yes then how?
I just want to make my chat screen update the message instantly when current user receives a message from another user.
Well, for update the message instantly when current user receives a message from another user you need to use firebase realtime database. it provides you to live data instantly..(for more info refer this tutorial https://medium.com/#platypus/react-native-chat-application-679dbff3ccd3)
and for other option Socket.io also provides live data and it is better than firebase realtime database.

Notification in web application when a database is updated

i am trying to develop a web application, which should show a notification ( similar to facebook notifications) whenever there is an update in a database.
Could someone please help me with the notifications part? are there any third party tools/plugins which can achieve this?
Thanks
First of all what kind of technologies are you using? (Backend and FrontEnd)
In a general way you need 2 things:
Backend after a DB update sends notifications through Websockets to notify all clients.
Clients subscribes the notifications and when receives a notification, then updates the UI.

Connecting to specific clients in a chat app

Im making a simple chat app that sends messages through a redis pub/sub channel. I do not use any login options just lets the user select a username and chat. I am trying to implement private chat where one client is able to communicate to another connect client. I am new to chat client programming, I am trying to figure out how to communicate with only one client. What are some options I could consider to get the ability to chat 1 on 1? I don't mind changing my architecture to incorporate a new tool. Any suggestions is appreciated
I did something similar with raw sockets. I held user objects which contained the connected socket, the name, and whether they are chatting. If a user is not in chat he can type a command /list users which gives the list of users currently connected. When he has found someone to chat with he enters the command /chat bob. If the user bob is already chatting he will receive a message from the server saying that bob is in a chat already. Otherwise a chat session will be established between the two users. They now will be in chat until one of them enters /endchat. Then they will be able to find new people to chat with.
The trick is implementing the server so it can track a list of users and their chatting status and who they are in chat with so when ever they type /endchat the other user can be notified.
The combination of Nodejs + Socket.io would solve your problem i suppose. Specifically rooms functionality is what you are looking for here.
Lets say you have two users bob and gob. Considering both are online (although you can add Redis as a session store and for storing history later, which i did in my case). Say bob wants to chat with gob he selects gob. Now make bob join a room using
var roomname = 'bob'>'gob'?'bob'+'gob':'gob'+'bob' ;
//this type of naming ensures roomname is same for both users
socket.join(roomname);
This will work only if both have chosen each other. So now when gob selects bob both are joined in the same room. Whenever someone sends a message make them emit to that room using
socket.broadcast.to(roomname).emit('message_event',msgObj);
Make sure you have have added the listener
socket.on('message_event',messageHandler);
When chat is finished make them leave the room using
socket.leave(roomname);

send facebook message using mobile application on Qt

I have a QML application and I am using functions in Javascript to "communicate" with Facebook Graph API. I have succeeded to post on my friend's wall but Now I want to send him a message to his inbox(private message). I noticed that Graph API doesn't support this So is there any other way to send the message? does Facebook offer any payed api that may help me ?!!
Thanks
Facebook inbox and chat share the same Facebook backend , in fact , as you know , we could call it chat if online , inbox if offline
So to send message you should refer to Facebook chat docs
It requires an XMPP authentication and it can be done with some Qt/C++ glue to the QML UI
see https://developers.facebook.com/docs/chat/

Categories

Resources