[+] 协议
This commit is contained in:
@@ -224,8 +224,8 @@ public final class ErrorUtils {
|
||||
if(StringUtils.isNotEmpty(message) && messageCode != MessageCode.CODE_9999) {
|
||||
return message;
|
||||
}
|
||||
// 包含中文直接返回:自定义的错误
|
||||
if(StringUtils.isNotEmpty(message) && message.matches(".*[\\u4e00-\\u9fa5]+.*")) {
|
||||
// 少量信息返回异常信息
|
||||
if(StringUtils.isNotEmpty(message) && message.length() <= Byte.MAX_VALUE) {
|
||||
return message;
|
||||
}
|
||||
// 其他情况不能直接返回异常信息
|
||||
|
||||
@@ -11,10 +11,6 @@ import com.acgist.taoyao.signal.protocol.control.ControlBellProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.control.ControlPhotographProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.control.ControlPtzProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.control.ControlRecordProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.platform.PlatformRebootProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.platform.PlatformShutdownProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.system.SystemRebootProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.system.SystemShutdownProtocol;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -33,26 +29,18 @@ public class ControlController {
|
||||
|
||||
private final ControlPtzProtocol controlPtzProtocol;
|
||||
private final ControlBellProtocol controlBellProtocol;
|
||||
private final SystemRebootProtocol systemRebootProtocol;
|
||||
private final ControlRecordProtocol controlRecordProtocol;
|
||||
private final SystemShutdownProtocol systemShutdownProtocol;
|
||||
private final PlatformRebootProtocol platformRebootProtocol;
|
||||
private final PlatformShutdownProtocol platformShutdownProtocol;
|
||||
private final ControlPhotographProtocol controlPhotographProtocol;
|
||||
|
||||
public ControlController(
|
||||
ControlPtzProtocol controlPtzProtocol, ControlBellProtocol controlBellProtocol,
|
||||
SystemRebootProtocol systemRebootProtocol, ControlRecordProtocol controlRecordProtocol,
|
||||
SystemShutdownProtocol systemShutdownProtocol, PlatformRebootProtocol platformRebootProtocol,
|
||||
PlatformShutdownProtocol platformShutdownProtocol, ControlPhotographProtocol controlPhotographProtocol
|
||||
ControlPtzProtocol controlPtzProtocol,
|
||||
ControlBellProtocol controlBellProtocol,
|
||||
ControlRecordProtocol controlRecordProtocol,
|
||||
ControlPhotographProtocol controlPhotographProtocol
|
||||
) {
|
||||
this.controlPtzProtocol = controlPtzProtocol;
|
||||
this.controlBellProtocol = controlBellProtocol;
|
||||
this.systemRebootProtocol = systemRebootProtocol;
|
||||
this.controlRecordProtocol = controlRecordProtocol;
|
||||
this.systemShutdownProtocol = systemShutdownProtocol;
|
||||
this.platformRebootProtocol = platformRebootProtocol;
|
||||
this.platformShutdownProtocol = platformShutdownProtocol;
|
||||
this.controlPhotographProtocol = controlPhotographProtocol;
|
||||
}
|
||||
|
||||
@@ -88,32 +76,4 @@ public class ControlController {
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "重启系统", description = "重启系统")
|
||||
@GetMapping("/system/reboot")
|
||||
public Message systemReboot() {
|
||||
this.systemRebootProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭系统", description = "关闭系统")
|
||||
@GetMapping("/system/shutdown")
|
||||
public Message systemShutdown() {
|
||||
this.systemShutdownProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "重启平台", description = "重启平台")
|
||||
@GetMapping("/platform/reboot")
|
||||
public Message platformReboot() {
|
||||
this.platformRebootProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭平台", description = "关闭平台")
|
||||
@GetMapping("/platform/shutdown")
|
||||
public Message platformShutdown() {
|
||||
this.platformShutdownProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.acgist.taoyao.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.signal.protocol.platform.PlatformRebootProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.platform.PlatformShutdownProtocol;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
/**
|
||||
* 平台
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Tag(name = "平台", description = "平台管理")
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/platform")
|
||||
public class PlatformController {
|
||||
|
||||
private final PlatformRebootProtocol platformRebootProtocol;
|
||||
private final PlatformShutdownProtocol platformShutdownProtocol;
|
||||
|
||||
public PlatformController(
|
||||
@Autowired(required = false) PlatformRebootProtocol platformRebootProtocol,
|
||||
@Autowired(required = false) PlatformShutdownProtocol platformShutdownProtocol
|
||||
) {
|
||||
this.platformRebootProtocol = platformRebootProtocol;
|
||||
this.platformShutdownProtocol = platformShutdownProtocol;
|
||||
}
|
||||
|
||||
@Operation(summary = "重启平台", description = "重启平台")
|
||||
@GetMapping("/reboot")
|
||||
public Message platformReboot() {
|
||||
this.platformRebootProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭平台", description = "关闭平台")
|
||||
@GetMapping("/shutdown")
|
||||
public Message platformShutdown() {
|
||||
this.platformShutdownProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.acgist.taoyao.controller;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.signal.protocol.system.SystemRebootProtocol;
|
||||
import com.acgist.taoyao.signal.protocol.system.SystemShutdownProtocol;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
/**
|
||||
* 系统
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Tag(name = "系统", description = "系统管理")
|
||||
@Validated
|
||||
@RestController
|
||||
@RequestMapping("/system")
|
||||
public class SystemController {
|
||||
|
||||
private final SystemRebootProtocol systemRebootProtocol;
|
||||
private final SystemShutdownProtocol systemShutdownProtocol;
|
||||
|
||||
public SystemController(
|
||||
@Autowired(required = false) SystemRebootProtocol systemRebootProtocol,
|
||||
@Autowired(required = false) SystemShutdownProtocol systemShutdownProtocol
|
||||
) {
|
||||
this.systemRebootProtocol = systemRebootProtocol;
|
||||
this.systemShutdownProtocol = systemShutdownProtocol;
|
||||
}
|
||||
|
||||
@Operation(summary = "重启系统", description = "重启系统")
|
||||
@GetMapping("/reboot")
|
||||
public Message systemReboot() {
|
||||
this.systemRebootProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭系统", description = "关闭系统")
|
||||
@GetMapping("/shutdown")
|
||||
public Message systemShutdown() {
|
||||
this.systemShutdownProtocol.execute();
|
||||
return Message.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.acgist.taoyao.signal;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.acgist.taoyao.annotation.TaoyaoTest;
|
||||
import com.acgist.taoyao.boot.model.MessageCodeException;
|
||||
import com.acgist.taoyao.main.TaoyaoApplication;
|
||||
import com.acgist.taoyao.signal.protocol.platform.PlatformErrorProtocol;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@TaoyaoTest(classes = TaoyaoApplication.class)
|
||||
public class PlatformErrorProtocolTest {
|
||||
|
||||
@Autowired
|
||||
private PlatformErrorProtocol platformErrorProtocol;
|
||||
|
||||
@Test
|
||||
public void testException() {
|
||||
log.info("{}", this.platformErrorProtocol.build(MessageCodeException.of("自定义")));
|
||||
log.info("{}", this.platformErrorProtocol.build(new NullPointerException("空指针")));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -90,13 +90,13 @@ public class ProtocolManager {
|
||||
final Message message = JSONUtils.toJava(content, Message.class);
|
||||
if(message == null) {
|
||||
log.warn("信令消息格式错误(解析失败):{}", content);
|
||||
client.push(this.platformErrorProtocol.build("信令消息格式错误(解析失败)"));
|
||||
client.push(this.platformErrorProtocol.build(MessageCode.CODE_1002, "信令消息格式错误(解析失败)"));
|
||||
return;
|
||||
}
|
||||
final Header header = message.getHeader();
|
||||
if(header == null) {
|
||||
log.warn("信令消息格式错误(没有头部):{}", content);
|
||||
client.push(this.platformErrorProtocol.build("信令消息格式错误(没有头部)"));
|
||||
client.push(this.platformErrorProtocol.build(MessageCode.CODE_1002, "信令消息格式错误(没有头部)"));
|
||||
return;
|
||||
}
|
||||
final String v = header.getV();
|
||||
@@ -106,14 +106,14 @@ public class ProtocolManager {
|
||||
this.platformErrorProtocol.set(id);
|
||||
if(v == null || id == null || signal == null) {
|
||||
log.warn("信令消息格式错误(缺失头部关键参数):{}", content);
|
||||
client.push(this.platformErrorProtocol.build("信令消息格式错误(缺失头部关键参数)"));
|
||||
client.push(this.platformErrorProtocol.build(MessageCode.CODE_1002, "信令消息格式错误(缺失头部关键参数)"));
|
||||
return;
|
||||
}
|
||||
// 开始处理协议
|
||||
final Protocol protocol = this.protocolMapping.get(signal);
|
||||
if(protocol == null) {
|
||||
log.warn("不支持的信令协议:{}", content);
|
||||
client.push(this.platformErrorProtocol.build("不支持的信令协议:" + signal));
|
||||
client.push(this.platformErrorProtocol.build(MessageCode.CODE_3415, "不支持的信令协议:" + signal));
|
||||
return;
|
||||
}
|
||||
if(log.isDebugEnabled()) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.acgist.taoyao.signal.protocol.platform;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
@@ -21,7 +23,7 @@ public class PlatformErrorProtocol extends ProtocolClientAdapter {
|
||||
public static final String SIGNAL = "platform::error";
|
||||
|
||||
/**
|
||||
* 请求ID缓存
|
||||
* 绑定线程请求ID
|
||||
*/
|
||||
private ThreadLocal<Long> idLocal = new InheritableThreadLocal<>();
|
||||
|
||||
@@ -56,10 +58,14 @@ public class PlatformErrorProtocol extends ProtocolClientAdapter {
|
||||
*/
|
||||
public Message build(Exception e) {
|
||||
final Message message = super.build();
|
||||
if(e instanceof MessageCodeException code) {
|
||||
message.setCode(code.getCode(), code.getMessage());
|
||||
final String exceptionMessage = e.getMessage();
|
||||
if(e instanceof MessageCodeException messageCodeException) {
|
||||
// 自定义的异常
|
||||
message.setCode(messageCodeException.getCode(), messageCodeException.getMessage());
|
||||
} else if(StringUtils.isNotEmpty(exceptionMessage) && exceptionMessage.length() <= Byte.MAX_VALUE) {
|
||||
// 少量信息返回异常信息
|
||||
message.setMessage(exceptionMessage);
|
||||
}
|
||||
message.setBody(e.getMessage());
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@Slf4j
|
||||
@Description(
|
||||
flow = "终端->信令服务+)终端"
|
||||
flow = {
|
||||
"信令服务+)终端",
|
||||
"终端->信令服务+)终端"
|
||||
}
|
||||
)
|
||||
public class PlatformRebootProtocol extends ProtocolClientAdapter implements ControlProtocol {
|
||||
|
||||
@@ -32,21 +35,29 @@ public class PlatformRebootProtocol extends ProtocolClientAdapter implements Con
|
||||
super("重启平台信令", SIGNAL);
|
||||
this.scriptProperties = scriptProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令信令
|
||||
*/
|
||||
public void execute() {
|
||||
log.info("重启平台");
|
||||
this.clientManager.broadcast(this.build());
|
||||
ScriptUtils.execute(this.scriptProperties.getPlatformReboot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
log.info("重启平台:{}", clientId);
|
||||
this.clientManager.broadcast(message);
|
||||
ScriptUtils.execute(this.scriptProperties.getPlatformReboot());
|
||||
this.reboot(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启平台
|
||||
*/
|
||||
public void execute() {
|
||||
log.info("重启平台");
|
||||
this.reboot(this.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启平台
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
private void reboot(Message message) {
|
||||
this.clientManager.broadcast(message);
|
||||
ScriptUtils.execute(this.scriptProperties.getPlatformReboot());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,7 +22,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@Slf4j
|
||||
@Description(
|
||||
flow = "终端->信令服务+)终端"
|
||||
flow = {
|
||||
"信令服务+)终端",
|
||||
"终端->信令服务+)终端"
|
||||
}
|
||||
)
|
||||
public class PlatformShutdownProtocol extends ProtocolClientAdapter implements ControlProtocol {
|
||||
|
||||
@@ -38,23 +41,24 @@ public class PlatformShutdownProtocol extends ProtocolClientAdapter implements C
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
log.info("关闭平台:{}", clientId);
|
||||
this.clientManager.broadcast(message);
|
||||
this.shutdown();
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令信令
|
||||
*/
|
||||
public void execute() {
|
||||
log.info("关闭平台");
|
||||
this.clientManager.broadcast(this.build());
|
||||
this.shutdown();
|
||||
this.shutdown(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭平台
|
||||
*/
|
||||
private void shutdown() {
|
||||
public void execute() {
|
||||
log.info("关闭平台");
|
||||
this.shutdown(this.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭平台
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
private void shutdown(Message message) {
|
||||
this.clientManager.broadcast(message);
|
||||
if(this.applicationContext instanceof ConfigurableApplicationContext context) {
|
||||
// API关闭
|
||||
if(context.isActive()) {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.acgist.taoyao.signal.protocol.system;
|
||||
|
||||
/**
|
||||
* 平台磁盘空间信令
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class SystemDiskspaceProtocol {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.acgist.taoyao.signal.protocol.system;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.acgist.taoyao.boot.annotation.Description;
|
||||
import com.acgist.taoyao.boot.annotation.Protocol;
|
||||
import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.boot.utils.FileUtils;
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.client.ClientType;
|
||||
import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 系统信息信令
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
@Protocol
|
||||
@Description
|
||||
public class SystemInfoProtocol extends ProtocolClientAdapter {
|
||||
|
||||
public static final String SIGNAL = "system::info";
|
||||
|
||||
public SystemInfoProtocol() {
|
||||
super("系统信息信令", SIGNAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
final Map<String, Object> info = new HashMap<>();
|
||||
// 硬盘
|
||||
final List<Diskspace> diskspace = new ArrayList<>();
|
||||
// File.listRoots(); -> 不全
|
||||
// FileSystems.getDefault().getFileStores(); -> 重复
|
||||
Stream.of(File.listRoots()).forEach(v -> {
|
||||
diskspace.add(new Diskspace(v.getPath(), v.getTotalSpace(), v.getFreeSpace()));
|
||||
});
|
||||
info.put("diskspace", diskspace);
|
||||
// 内存
|
||||
final Runtime runtime = Runtime.getRuntime();
|
||||
info.put("maxMemory", runtime.maxMemory());
|
||||
info.put("freeMemory", runtime.freeMemory());
|
||||
info.put("totalMemory", runtime.totalMemory());
|
||||
info.put("maxMemoryGracefully", FileUtils.formatSize(runtime.maxMemory()));
|
||||
info.put("freeMemoryGracefully", FileUtils.formatSize(runtime.freeMemory()));
|
||||
info.put("totalMemoryGracefully", FileUtils.formatSize(runtime.totalMemory()));
|
||||
// 其他
|
||||
info.put("osName", System.getProperty("os.name"));
|
||||
info.put("osArch", System.getProperty("os.arch"));
|
||||
info.put("osVersion", System.getProperty("os.version"));
|
||||
info.put("javaVmName", System.getProperty("java.vm.name"));
|
||||
info.put("javaVersion", System.getProperty("java.version"));
|
||||
info.put("cpuProcessors", runtime.availableProcessors());
|
||||
// 响应
|
||||
client.push(this.build(info));
|
||||
};
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public static final class Diskspace {
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private final String path;
|
||||
/**
|
||||
* 总量
|
||||
*/
|
||||
private final Long total;
|
||||
/**
|
||||
* 空闲
|
||||
*/
|
||||
private final Long free;
|
||||
/**
|
||||
* 总量
|
||||
*/
|
||||
private final String totalGracefully;
|
||||
/**
|
||||
* 空闲
|
||||
*/
|
||||
private final String freeGracefully;
|
||||
|
||||
public Diskspace(String path, Long total, Long free) {
|
||||
this.path = path;
|
||||
this.total = total;
|
||||
this.free = free;
|
||||
this.totalGracefully = FileUtils.formatSize(total);
|
||||
this.freeGracefully = FileUtils.formatSize(free);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,7 +20,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@Slf4j
|
||||
@Description(
|
||||
flow = "终端->信令服务+)终端"
|
||||
flow = {
|
||||
"信令服务+)终端",
|
||||
"终端->信令服务+)终端"
|
||||
}
|
||||
)
|
||||
public class SystemRebootProtocol extends ProtocolClientAdapter implements ControlProtocol {
|
||||
|
||||
@@ -32,21 +35,29 @@ public class SystemRebootProtocol extends ProtocolClientAdapter implements Contr
|
||||
super("重启系统信令", SIGNAL);
|
||||
this.scriptProperties = scriptProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令信令
|
||||
*/
|
||||
public void execute() {
|
||||
log.info("重启系统");
|
||||
this.clientManager.broadcast(this.build());
|
||||
ScriptUtils.execute(this.scriptProperties.getSystemReboot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
log.info("重启系统:{}", clientId);
|
||||
this.clientManager.broadcast(message);
|
||||
ScriptUtils.execute(this.scriptProperties.getSystemReboot());
|
||||
this.reboot(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启系统
|
||||
*/
|
||||
public void execute() {
|
||||
log.info("重启系统");
|
||||
this.reboot(this.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启系统
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
private void reboot(Message message) {
|
||||
this.clientManager.broadcast(message);
|
||||
ScriptUtils.execute(this.scriptProperties.getSystemReboot());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@Slf4j
|
||||
@Description(
|
||||
flow = "终端->信令服务+)终端"
|
||||
flow = {
|
||||
"信令服务+)终端",
|
||||
"终端->信令服务+)终端"
|
||||
}
|
||||
)
|
||||
public class SystemShutdownProtocol extends ProtocolClientAdapter implements ControlProtocol {
|
||||
|
||||
@@ -33,20 +36,28 @@ public class SystemShutdownProtocol extends ProtocolClientAdapter implements Con
|
||||
this.scriptProperties = scriptProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令信令
|
||||
*/
|
||||
public void execute() {
|
||||
log.info("关闭系统");
|
||||
this.clientManager.broadcast(this.build());
|
||||
ScriptUtils.execute(this.scriptProperties.getSystemShutdown());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
log.info("关闭系统:{}", clientId);
|
||||
this.clientManager.broadcast(message);
|
||||
ScriptUtils.execute(this.scriptProperties.getSystemShutdown());
|
||||
this.shutdown(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行命令信令
|
||||
*/
|
||||
public void execute() {
|
||||
log.info("关闭系统");
|
||||
this.shutdown(this.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭系统
|
||||
*
|
||||
* @param message 消息
|
||||
*/
|
||||
private void shutdown(Message message) {
|
||||
this.clientManager.broadcast(message);
|
||||
ScriptUtils.execute(this.scriptProperties.getSystemShutdown());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user