Client Code:
$scope.socket = new SockJS("ws/ws");
$scope.stompClient = Stomp.over($scope.socket);
$scope.stompClient.connect("guest", "guest",connectCallback, errorCallback);
//in connectCallback
$scope.stompClient.subscribe('/topic/agent-sendstatus', showScreenPop);
Java Code:
@MessageMapping("/agent-sendstatus")
public void testmethod()
{
//How do i get ServletContext here to further implement solution?
template.convertAndSend("/topic/agent-sendstatus","bcd");
}
请建议。我在控制器中使用 SimpMessageHeaderAccessor 获得会话,但我也需要 ServletContext。春天有什么办法吗?