Add websocket example
This commit is contained in:
@@ -8,19 +8,12 @@ import org.baeldung.model.OutputMessage;
|
||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@Controller
|
||||
public class ChatController {
|
||||
|
||||
@RequestMapping(value = "/showChat", method = RequestMethod.GET)
|
||||
public String displayChat() {
|
||||
return "chat";
|
||||
}
|
||||
|
||||
@MessageMapping("/chat")
|
||||
@SendTo("/topic/")
|
||||
@SendTo("/topic/messages")
|
||||
public OutputMessage send(final Message message) throws Exception {
|
||||
|
||||
final String time = new SimpleDateFormat("HH:mm").format(new Date());
|
||||
|
||||
Reference in New Issue
Block a user