나는 websocket을 사용하고 있습니다.
서버에 "메시지"를 보내고 싶습니다.
예) 클라이언트에서
function do_sync() {
stompClient.send("/action/test", {}, "message");
}
하지만 컨트롤러에서 "메시지"를받는 방법을 모르겠습니다.
@MessageMapping("/test")
public void sync() throws Exception {
String message = ex) message from client.
}
컨트롤러에서 메시지를 받으려면 어떻게해야합니까?
실제로 특별한 것은 필요하지 않습니다. websocket 메시지 payload
는 단순히 메소드 매개 변수에 매핑 될 수 있습니다.
@MessageMapping("/test")
public void sync(String payload) throws Exception {
....
}
문서에서 더 많은 것을 읽으십시오 : http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-stomp-handle-annotations
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다