-
Notifications
You must be signed in to change notification settings - Fork 0
Working Mechanism
-
Initially the user sends an HTTPS request to the server for the WebSocket connection, and the server responds back by upgrading the existing connection to the WebSocket and runs on a separate server. Hence a bi-directional communication protocol has been established between user(s) and server.
-
Upon the successful connection, the user lands on the chat screen where he inputs his username. As soon as he enters the username and clicks submit, a method will be called in Backend JavaScript which routes the traffic between the WebSocket server and the client.
-
Everything is defined/encoded as message to the WebSocket server. When the user joins, a message of type ‘JOIN’ will be called and the method will be handled by controller class in spring boot, which has methods named
@SendTo&@MessageMappingmethods -
These two methods get called whenever the
USER JOINED,LEFT&SENDaMESSAGE. These methods will handle the payload (message data) and broadcasts that to the other users who already joined the chat. -
The WebSocket Listener Class in the controller will handle whenever a user Leaves a session and it also keep log of every activity happened during the session.