| 12345678910111213141516171819202122232425262728293031 |
- package top.haijunit.train.controller;
- import top.haijunit.train.websocket.WebSocketServer;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.bind.annotation.GetMapping;
- import org.springframework.web.bind.annotation.PathVariable;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RestController;
- import org.springframework.web.servlet.ModelAndView;
- /**
- * @author zhanghaijun
- * @date 2023/11/3 16:36
- * @description 测试websocket界面
- */
- @RestController
- public class WebSocketController {
- @GetMapping("/page")
- public ModelAndView page() {
- return new ModelAndView("webSocket");
- }
- @RequestMapping("/push/{toUID}")
- public ResponseEntity<String> pushToClient(String message, @PathVariable String toUID) throws Exception {
- WebSocketServer.sendInfo(message, toUID);
- return ResponseEntity.ok("Send Success!");
- }
- }
|