From 094713f982c2744b3d4985c0b20a5837dab47597 Mon Sep 17 00:00:00 2001 From: onfranciis Date: Tue, 26 Sep 2023 05:51:48 +0100 Subject: [PATCH] feat: add notification broadcast on disconnect --- utils/user.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/user.ts b/utils/user.ts index 7c03236..11cd19d 100644 --- a/utils/user.ts +++ b/utils/user.ts @@ -2,7 +2,7 @@ import { Data, WebSocket } from "ws"; import { v4 as uuid } from "uuid"; import { messagesDataType, usersType } from "./types"; import moment from "moment"; -import { numberOfUsers } from "./message"; +import { numberOfUsers, toEveryoneExceptSender } from "./message"; export const users: usersType = {}; export const messagesData: messagesDataType[] = []; @@ -50,7 +50,7 @@ class User { delete users[ID]; console.log(`Number of connected users: ${Object.keys(users).length}`); broadcastMessage(numberOfUsers()); - broadcastMessage(`${ID} left the chat`); + toEveryoneExceptSender(ID, `${ID} has left the chat`, "notification"); } }