I am new to Server-Sent-Events, already using Sockets for the implementation, In which we store the Socket Session with particular user information in a static class which will be used to send messages when particular things happen in different servlets.
Like If an user sends a friend request store the request and its status in database and sent the notification to the respective user with their WebSocket sessions.
Like this way I try to send notifications to users,
So I want to maintain the connection, I see only demonstration of running an infinite loop and whenever there is a data available it is sending like that way only everyone was showing,
Other wise I thought to execute it with wait and notifyAll when there is a data comes
But it may lead to DeadLoack situation and holding the request or response object leads to security flaws
So give me an idea how to maintain the state of the user request.
How to implement sending the notification to particular user?
what are the ways to maintain the current logged in users who are waiting for notification ?
Implementation in Java Servlet.
Amal is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.