Skip to content

Commit

Permalink
update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
yennanliu committed Nov 13, 2023
1 parent a201454 commit 967c184
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions springChatRoom/src/main/resources/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function connect(event) {


function onConnected() {

// Subscribe to the Public Topic
stompClient.subscribe('/topic/public', onMessageReceived);

Expand All @@ -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');
}

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 967c184

Please sign in to comment.