package com.example.fuzzControll.controller.dataController; import com.example.fuzzControll.service.websocketClientService; import lombok.extern.slf4j.Slf4j; 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.RestController; /** * websocket 客户端 */ @Slf4j @RestController @RequestMapping("/websocket") public class WebsocketController { @Autowired websocketClientService websocketClientService; @RequestMapping(value = "/connect", method = RequestMethod.GET) public void connect(){ try { websocketClientService.connect(); } catch (Exception e) { e.printStackTrace(); } log.info("Connect success!"); } @RequestMapping(value = "/disConnect", method = RequestMethod.GET) public void disConnect(){ try { websocketClientService.disconnect(); } catch (Exception e) { e.printStackTrace(); } log.info("Disconnect success!"); } }