Skip to main content
2 of 2
deleted 11 characters in body
Ming
  • 71
  • 7

How to use user id instead of username when spring websocket stomp sends to a specified user?

I have a function module that sends notifications to users and there are two types of users, 1.one is an ordinary account, each account can only be online once at the same time

2.the other is an ip user, when an ip user logs in, it determines whether the user's ip is Within the scope of the ip user table, and the username is the real-time ip of the obtained user as the username.

3.When I use simpMessagingTemplate.convertAndSendToUser(String user, String destination, Object payload)) to send a notification to a specified user, for ordinary users, I can directly pass the username, and for ip users, only id without username, For the username of the ip user, the real-time ip obtained when the ip user logs in is used as the username

4.The problem now is that when I want to send a notification to the ip user, I only have the id of the ip user and not the user name of the ip user. I want to call simpMessagingTemplate.convertAndSendToUser(String user, String destination, Object payload)) to send to the specified user and replace the user name with id. Is there any way to achieve this?

Ming
  • 71
  • 7