In SimpMessageHeaderAccessor it cannot find the function getSessionAttributes().
I was using this code block. But the getSessionAttributes() was showing error. I used library "spring-messaging.jar-4.0.0 Release". I found on their website that this function exists in this class. But the library I've used doesn't contain this class. How can this be solved? I cannot update the class file and add the function!
@MessageMapping("/chat.addUser")
@SendTo("/topic/public")
public ChatMessage addUser(@Payload ChatMessage chatMessage,
SimpMessageHeaderAccessor headerAccessor) {
// Add username in web socket session
headerAccessor.getSessionAttributes().put("username", chatMessage.getSender());
return chatMessage;
}
Answers ( 1 )
You can use Spring Messaging version 4.1.6 in your pom.xML file. Hopefully it will be okay.
You will find all versions here
https://mvnrepository.com/artifact/org.springframework/spring-messaging