package com.changfa.controller; import com.changfa.config.WebSocketServer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import java.io.IOException; @RestController @RequestMapping("/ws") public class WebSocketController { @Autowired private WebSocketServer webSocketServer; @RequestMapping(value = "/push",method = RequestMethod.GET) @ResponseBody public Object push(String message,String userId) throws IOException { webSocketServer.sendInfo(message,userId); return "操作成功"; } }