I searched for it all day and found a similar answer to the google, that I was able to get home, but I don"t think I can make it clear where this user came from.
my English is not good, and I use translation software, which may be the reason why I can"t understand it
from-in-convertandsendtouser-works-in-sockjsspring-websocket/47956531" rel=" nofollow noreferrer "> https://stackoverflow.com/que.
so I hope someone can give me an answer
convertAndSendToUser (username, destination, message) API.
it accepts a string user name, which means that if we somehow set a unique user name for each connection, we should be able to send messages to specific users who subscribe to the topic.
what I don"t understand is, where did this user name come from?
the user name is an instance of the java.security.Principal class. But how is this Principal object obtained, how is it stored in spring, how do I make some business judgments based on this user to decide whether to send a message, and if the current user is A, send a message to B, how can this requirement be realized?