增加websocket
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package com.onekeycall.videotablet.controller;
|
||||
|
||||
import com.onekeycall.videotablet.handler.CustomWebSocketHandler;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/ws")
|
||||
public class WebSocketController {
|
||||
|
||||
private final CustomWebSocketHandler webSocketHandler;
|
||||
|
||||
public WebSocketController(CustomWebSocketHandler webSocketHandler) {
|
||||
this.webSocketHandler = webSocketHandler;
|
||||
}
|
||||
|
||||
@PostMapping("/broadcast")
|
||||
public ResponseEntity<String> broadcast(@RequestBody String message) {
|
||||
webSocketHandler.broadcast(message);
|
||||
return ResponseEntity.ok("广播发送成功");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user