From 967c184d603f570aa7704ebd65dd1c33ac0d3a54 Mon Sep 17 00:00:00 2001 From: yennanliu Date: Mon, 13 Nov 2023 17:55:47 +0800 Subject: [PATCH] update main.js --- springChatRoom/src/main/resources/static/js/main.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/springChatRoom/src/main/resources/static/js/main.js b/springChatRoom/src/main/resources/static/js/main.js index f6f894373..bd9b10c75 100644 --- a/springChatRoom/src/main/resources/static/js/main.js +++ b/springChatRoom/src/main/resources/static/js/main.js @@ -38,6 +38,7 @@ function connect(event) { function onConnected() { + // Subscribe to the Public Topic stompClient.subscribe('/topic/public', onMessageReceived); @@ -47,6 +48,11 @@ function onConnected() { JSON.stringify({sender: username, type: 'JOIN'}) ) + // Subscribe to private topic +// stompClient.subscribe('/user/topic/private/{channelId}', (message) => { +// // Handle incoming private messages +// }); + connectingElement.classList.add('hidden'); } @@ -143,6 +149,11 @@ function updateOnlineUsers(users) { }); } +// private msg (user - user) +//function sendMessage(channelId, message) { +// stompClient.send(`/app/private/${channelId}`, {}, JSON.stringify(message)); +//} + // Call the fetchUserList function to initially populate the user list fetchUserList();