Added new websocket endpoint
This commit is contained in:
parent
5f01174764
commit
21fa7b5e64
@ -1,5 +1,8 @@
|
||||
package org.ros.chatto.websocket;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.ros.chatto.model.ChatMessage;
|
||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
@ -14,11 +17,20 @@ public class WebSocketController {
|
||||
|
||||
private final SimpMessagingTemplate smt;
|
||||
|
||||
@MessageMapping("/chat2")
|
||||
// @SendTo("/topic/messages")
|
||||
// @SendToUser("/queue/reply")
|
||||
public void send2(@Payload final Message message) throws Exception {
|
||||
smt.convertAndSendToUser(message.getTo(), "/queue/reply", message);
|
||||
// return message;
|
||||
}
|
||||
|
||||
@MessageMapping("/chat")
|
||||
// @SendTo("/topic/messages")
|
||||
// @SendToUser("/queue/reply")
|
||||
public void send(@Payload final Message message) throws Exception {
|
||||
smt.convertAndSendToUser(message.getTo(), "/queue/reply", message);
|
||||
public void send(@Valid final ChatMessage message) throws Exception {
|
||||
smt.convertAndSendToUser(message.getToUser().getUserName(),
|
||||
"/queue/reply", message);
|
||||
// return message;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
}
|
||||
|
||||
function connect() {
|
||||
var socket = new SockJS('/chat');
|
||||
var socket = new SockJS('/chat2');
|
||||
stompClient = Stomp.over(socket);
|
||||
stompClient.connect({}, function (frame) {
|
||||
setConnected(true);
|
||||
|
Loading…
Reference in New Issue
Block a user