This is an introduction to websockets from client and server.
This product is the implementation of a Websocket backend Livechat connected to a third party client, in our case is our company's Widget, Facebook Messenger, WeChat, Telegram etc.
Summary:
- A user shall request for a LiveChat Agent to attend to his question.
- On the Agent's browser, a request for livechat should showup where the users will be able to either "Accept" or "Decline".
- If the Agent Accepts, a websocket will be established and a customized message can be published to the Gateway (e.g. xxx has entered the chat) which will then be forwarded to the user.
- The status of the room will be changed to engaged, and no other users can enter this room after. The livechat will remain connected until the agent terminates the session.
- x amount of messages(configurable from Database), can be loaded upon entering the page.
- Each agent will have their own version of Canned Response to increase their efficiency in replying commonly asked question.
- When an Agent disconnects, the websocket will be terminated and a customized messaged will be sent to the Agent as well.
Production Code is inside the folder livechat with the following techstack
- MongoDB(Mongoose), Socket.io, RabbitMQ, Docker
Features:
- Scalable through the use of publisher/subscriber pattern through the use of RabbitMQ
- Reconnection when connection is dropped for RabbitMQ and MongoDB Database
- Use of authentication middleware for REST and websocket connections
- Use of error handling middleware for REST endpoints
- PBKDF2-SHA512 + randomized salt for encryption
- Clean and modular code, DRY Principle and SOLID principle (adapted from the code Clean Code)
- Object-Oriented programming
Project Requirements:
- Permission Group for different users
- Load Messages upon entering
- Canned Response for Agents to customize