Skip to content

Working Mechanism

JayaShankar Mangina edited this page Feb 1, 2022 · 1 revision
  1. 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.

  2. 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.

  3. 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 & @MessageMapping methods

  4. These two methods get called whenever the USER JOINED, LEFT & SEND a MESSAGE. These methods will handle the payload (message data) and broadcasts that to the other users who already joined the chat.

  5. 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.

Clone this wiki locally