Skip to content

Commit

Permalink
Merge pull request #5 from onfranciis/dev
Browse files Browse the repository at this point in the history
feat: add notification broadcast on disconnect
  • Loading branch information
onfranciis authored Sep 27, 2023
2 parents 53a09d1 + 094713f commit 4a2a677
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -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");
}
}

Expand Down

0 comments on commit 4a2a677

Please sign in to comment.