26 lines
894 B
Java
26 lines
894 B
Java
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("广播发送成功");
|
|
}
|
|
}
|