[*] 日常优化
This commit is contained in:
@@ -35,24 +35,24 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
||||
)
|
||||
public class MediaRouterRtpCapabilitiesProtocol extends ProtocolRoomAdapter {
|
||||
|
||||
public static final String SIGNAL = "media::router::rtp::capabilities";
|
||||
|
||||
public MediaRouterRtpCapabilitiesProtocol() {
|
||||
super("路由RTP协商信令", SIGNAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public static final String SIGNAL = "media::router::rtp::capabilities";
|
||||
|
||||
public MediaRouterRtpCapabilitiesProtocol() {
|
||||
super("路由RTP协商信令", SIGNAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean authenticate(Room room, Client client) {
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
client.push(room.requestMedia(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||
if(clientType.mediaClient()) {
|
||||
client.push(room.requestMedia(message));
|
||||
} else {
|
||||
this.logNoAdapter(clientType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,11 +28,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
"audio" : 是否需要声音(true|false),
|
||||
"video" : 是否需要视频(true|false)
|
||||
}
|
||||
""",
|
||||
flow = {
|
||||
"终端->信令服务->终端",
|
||||
"终端=>信令服务->终端"
|
||||
{
|
||||
"name" : "终端名称",
|
||||
"clientId" : "终端ID",
|
||||
"sessionId": "会话ID"
|
||||
}
|
||||
""",
|
||||
flow = "终端=>信令服务->终端"
|
||||
)
|
||||
public class SessionCallProtocol extends ProtocolSessionAdapter {
|
||||
|
||||
|
||||
@@ -23,9 +23,10 @@ import com.acgist.taoyao.signal.protocol.ProtocolSessionAdapter;
|
||||
@Description(
|
||||
body = """
|
||||
{
|
||||
"sessionId": "会话ID"
|
||||
}
|
||||
""",
|
||||
flow = "终端->信令服务+)终端"
|
||||
flow = "终端->信令服务->终端"
|
||||
)
|
||||
public class SessionCloseProtocol extends ProtocolSessionAdapter implements ApplicationListener<SessionCloseEvent> {
|
||||
|
||||
|
||||
@@ -25,22 +25,22 @@ import com.acgist.taoyao.signal.protocol.ProtocolSessionAdapter;
|
||||
""",
|
||||
body = """
|
||||
{
|
||||
"sdp": "sdp"
|
||||
"type": "offer",
|
||||
"sdp" : "sdp"
|
||||
"type" : "offer",
|
||||
"sessionId": "会话ID"
|
||||
}
|
||||
{
|
||||
"sdp": "sdp"
|
||||
"type": "answer",
|
||||
"sdp" : "sdp"
|
||||
"type" : "answer",
|
||||
"sessionId": "会话ID"
|
||||
}
|
||||
{
|
||||
"type": "candidate",
|
||||
"type" : "candidate",
|
||||
"sessionId": "会话ID",
|
||||
"candidate": {
|
||||
"sdpMid": "sdpMid",
|
||||
"candidate": "candidate信息",
|
||||
"sdpMLineIndex":sdpMLineIndex
|
||||
"sdpMid" : "sdpMid",
|
||||
"candidate" : "candidate信息",
|
||||
"sdpMLineIndex": sdpMLineIndex
|
||||
}
|
||||
}
|
||||
""",
|
||||
|
||||
@@ -29,23 +29,24 @@ import lombok.Setter;
|
||||
{
|
||||
"diskspace": [
|
||||
{
|
||||
"path": "存储路径",
|
||||
"free": 存储空闲,
|
||||
"path" : "存储路径",
|
||||
"free" : 存储空闲,
|
||||
"total": 存储总量
|
||||
},
|
||||
...
|
||||
],
|
||||
"maxMemory": 最大能用内存,
|
||||
"freeMemory": 空闲内存,
|
||||
"totalMemory": 已用内存,
|
||||
"osArch": "系统架构",
|
||||
"osName": "系统名称",
|
||||
"osVersion": "系统版本",
|
||||
"javaVmName": "虚拟机名称",
|
||||
"javaVersion": "虚拟机版本",
|
||||
"maxMemory" : 最大能用内存,
|
||||
"freeMemory" : 空闲内存,
|
||||
"totalMemory" : 已用内存,
|
||||
"osArch" : "系统架构",
|
||||
"osName" : "系统名称",
|
||||
"osVersion" : "系统版本",
|
||||
"javaVmName" : "虚拟机名称",
|
||||
"javaVersion" : "虚拟机版本",
|
||||
"cpuProcessors": CPU核心数量
|
||||
}
|
||||
"""
|
||||
""",
|
||||
flow = "终端=>信令服务"
|
||||
)
|
||||
public class SystemInfoProtocol extends ProtocolClientAdapter {
|
||||
|
||||
@@ -82,7 +83,8 @@ public class SystemInfoProtocol extends ProtocolClientAdapter {
|
||||
info.put("javaVersion", System.getProperty("java.version"));
|
||||
info.put("cpuProcessors", runtime.availableProcessors());
|
||||
// 响应
|
||||
client.push(this.build(info));
|
||||
message.setBody(info);
|
||||
client.push(message);
|
||||
};
|
||||
|
||||
@Getter
|
||||
@@ -111,10 +113,10 @@ public class SystemInfoProtocol extends ProtocolClientAdapter {
|
||||
private final String totalGracefully;
|
||||
|
||||
public Diskspace(String path, Long free, Long total) {
|
||||
this.path = path;
|
||||
this.free = free;
|
||||
this.path = path;
|
||||
this.free = free;
|
||||
this.total = total;
|
||||
this.freeGracefully = FileUtils.formatSize(free);
|
||||
this.freeGracefully = FileUtils.formatSize(free);
|
||||
this.totalGracefully = FileUtils.formatSize(total);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,42 +21,43 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Description(
|
||||
flow = {
|
||||
"信令服务+)终端",
|
||||
"终端->信令服务+)终端"
|
||||
"终端->信令服务+)终端",
|
||||
"终端=>信令服务+)终端"
|
||||
}
|
||||
)
|
||||
public class SystemRebootProtocol extends ProtocolClientAdapter {
|
||||
|
||||
public static final String SIGNAL = "system::reboot";
|
||||
|
||||
private final ScriptProperties scriptProperties;
|
||||
|
||||
public SystemRebootProtocol(ScriptProperties scriptProperties) {
|
||||
super("重启系统信令", SIGNAL);
|
||||
this.scriptProperties = scriptProperties;
|
||||
}
|
||||
public static final String SIGNAL = "system::reboot";
|
||||
|
||||
private final ScriptProperties scriptProperties;
|
||||
|
||||
public SystemRebootProtocol(ScriptProperties scriptProperties) {
|
||||
super("重启系统信令", SIGNAL);
|
||||
this.scriptProperties = scriptProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
log.info("重启系统:{}", clientId);
|
||||
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());
|
||||
}
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
log.info("重启系统:{}", clientId);
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,42 +21,43 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@Description(
|
||||
flow = {
|
||||
"信令服务+)终端",
|
||||
"终端->信令服务+)终端"
|
||||
"终端->信令服务+)终端",
|
||||
"终端=>信令服务+)终端"
|
||||
}
|
||||
)
|
||||
public class SystemShutdownProtocol extends ProtocolClientAdapter {
|
||||
|
||||
public static final String SIGNAL = "system::shutdown";
|
||||
|
||||
private final ScriptProperties scriptProperties;
|
||||
|
||||
public SystemShutdownProtocol(ScriptProperties scriptProperties) {
|
||||
super("关闭系统信令", SIGNAL);
|
||||
this.scriptProperties = scriptProperties;
|
||||
}
|
||||
public static final String SIGNAL = "system::shutdown";
|
||||
|
||||
private final ScriptProperties scriptProperties;
|
||||
|
||||
public SystemShutdownProtocol(ScriptProperties scriptProperties) {
|
||||
super("关闭系统信令", SIGNAL);
|
||||
this.scriptProperties = scriptProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
log.info("关闭系统:{}", clientId);
|
||||
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());
|
||||
}
|
||||
@Override
|
||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||
log.info("关闭系统:{}", clientId);
|
||||
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