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 pushToClient(String message, @PathVariable String toUID) throws Exception { WebSocketServer.sendInfo(message, toUID); return ResponseEntity.ok("Send Success!"); } }