数字孪生后台
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.ruoyi.api.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.tcp.TcpServerManager;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/tcp")
|
||||
public class TcpServerController {
|
||||
private final TcpServerManager manager;
|
||||
|
||||
public TcpServerController(TcpServerManager manager) {
|
||||
this.manager = manager;
|
||||
}
|
||||
|
||||
@GetMapping("/status")
|
||||
public AjaxResult status() {
|
||||
return AjaxResult.success(manager.status());
|
||||
}
|
||||
|
||||
@PostMapping("/send/{channel}")
|
||||
public AjaxResult send(@PathVariable String channel, @RequestBody String message) {
|
||||
boolean ok = manager.broadcast(channel, message);
|
||||
if (ok) return AjaxResult.success();
|
||||
return AjaxResult.error("channel not found");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user