I am using websocket.
I want to send "message" to server.
ex) at Client
function do_sync() {
stompClient.send("/action/test", {}, "message");
}
but i don't know how to get "message" at Controller.
@MessageMapping("/test")
public void sync() throws Exception {
String message = ex) message from client.
}
how get message at Controller?
Actually you need nothing special: the websocket message payload
can be simply mapped to the method param:
@MessageMapping("/test")
public void sync(String payload) throws Exception {
....
}
Please, read more in Docs: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-handle-annotations