【发布时间】:2015-04-07 20:35:09
【问题描述】:
是否可以使用 STOMP 和 Spring 4 创建房间? Socket.IO内置了房间,所以我想知道Spring是否有这个
我现在的代码:
@MessageMapping("/room/greet/{room}")
@SendTo("/room/{room}")
public Greeting greet(@DestinationVariable String room, HelloMessage message) throws Exception {
return new Greeting("Hello, " + room + "!");
}
最好有@SendTo("/room/{room}")
但是,我仅限于:
@SendTo("/room/room1")
@SendTo("/room/room2")
@SendTo("/room/room3")
等等......这是非常非常不理想的
客户是:
stompClient.subscribe('/room/' + roomID, function(greeting){
showGreeting(JSON.parse(greeting.body).content);
});
其中 roomID 可以是 room1、room2 或 room3... 如果我想要更多房间怎么办?现在感觉好痛
【问题讨论】:
标签: spring websocket stomp spring-websocket