Skip to content

Commit 37f4b26

Browse files
Merge pull request #31 from Jayakrishnan-mk/dev
PR || fix(socket): test cases added for check from frontend console
2 parents 0df8b59 + 84e9621 commit 37f4b26

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/public/test-client.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<body>
1010
<h2>Socket.IO Client Test</h2>
1111
<script> // dummy token. just for test purpose.........
12-
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwiaWF0IjoxNzQ1MDYxMjA4LCJleHAiOjE3NDUwNjQ4MDh9.qv1P4QHlIjwqy_8YFq1OLK7Bg_-RHxfapr6Bkcy24KI";
12+
const token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NCwiaWF0IjoxNzQ4NTE2MzMxLCJleHAiOjE3NDg1MTk5MzF9.3eDphhgsSZ9drk9Ww-6muUIZmnsxMW7byj2fdJPIUw0";
1313
const socket = io("http://localhost:3000", {
1414
auth: {
1515
token: token

src/ws/socket.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ export const initializeSocket = (server: Server): SocketIOServer => {
3737
socket.join(`user-${uid}`);
3838
console.log(`🧑‍💻 Socket ${socket.id} registered for user ${uid}`);
3939

40+
socket.on("send_notification", (data) => {
41+
console.log("📩 Received notification:", data);
42+
43+
// Optionally, emit back to the same socket or room for confirmation
44+
socket.emit("notification_ack", { status: "received", original: data });
45+
});
46+
4047
socket.on("disconnect", () => {
4148
userSocketMap.get(uid)?.delete(socket.id);
4249
if (userSocketMap.get(uid)?.size === 0) {

0 commit comments

Comments
 (0)