We enable the chatting feature within the IMS project by providing a group chat that is available to all users of the app. A WebSocket object can be used to create and manage WebSocket connections to a server. This object provides attributes that can be used to listen for events such as onopen, onclose, and onmessage. We make use of these events to build our chat component. A WebSocketService in the project provides a connect() method that the chat component calls when it's initialized. Here's the connect() method of WebSocketService:
private socket: WebSocket;
private listener: EventEmitter<any> = new EventEmitter();
public connect() {
const path = `ws://localhost:8084/ims-chat/chat`;
this.socket = new WebSocket(path);
this.socket.onmessage = event => {
this.listener.emit({ "type": "message"...