[*] 日常优化
This commit is contained in:
@@ -2524,6 +2524,20 @@ class Taoyao extends RemoteClient {
|
|||||||
return response.body;
|
return response.body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间状态信令
|
||||||
|
*
|
||||||
|
* @param {*} roomId 房间ID
|
||||||
|
*
|
||||||
|
* @returns 房间状态
|
||||||
|
*/
|
||||||
|
async roomStatus(roomId) {
|
||||||
|
const response = await this.request(protocol.buildMessage("room::status", {
|
||||||
|
roomId: roomId || this.roomId
|
||||||
|
}));
|
||||||
|
return response.body;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生产媒体
|
* 生产媒体
|
||||||
*
|
*
|
||||||
@@ -3072,13 +3086,11 @@ class Taoyao extends RemoteClient {
|
|||||||
await me.buildPeerConnection(session, sessionId);
|
await me.buildPeerConnection(session, sessionId);
|
||||||
session.peerConnection.createOffer().then(async (description) => {
|
session.peerConnection.createOffer().then(async (description) => {
|
||||||
await session.peerConnection.setLocalDescription(description);
|
await session.peerConnection.setLocalDescription(description);
|
||||||
me.push(
|
me.push(protocol.buildMessage("session::exchange", {
|
||||||
protocol.buildMessage("session::exchange", {
|
sdp : description.sdp,
|
||||||
sdp : description.sdp,
|
type : description.type,
|
||||||
type : description.type,
|
sessionId: sessionId
|
||||||
sessionId: sessionId
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3126,13 +3138,11 @@ class Taoyao extends RemoteClient {
|
|||||||
await session.peerConnection.setRemoteDescription(new RTCSessionDescription(message.body));
|
await session.peerConnection.setRemoteDescription(new RTCSessionDescription(message.body));
|
||||||
session.peerConnection.createAnswer().then(async description => {
|
session.peerConnection.createAnswer().then(async description => {
|
||||||
await session.peerConnection.setLocalDescription(description);
|
await session.peerConnection.setLocalDescription(description);
|
||||||
me.push(
|
me.push(protocol.buildMessage("session::exchange", {
|
||||||
protocol.buildMessage("session::exchange", {
|
sdp : description.sdp,
|
||||||
sdp : description.sdp,
|
type : description.type,
|
||||||
type : description.type,
|
sessionId: sessionId
|
||||||
sessionId: sessionId
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
} else if (type === "answer") {
|
} else if (type === "answer") {
|
||||||
await session.peerConnection.setRemoteDescription(new RTCSessionDescription(message.body));
|
await session.peerConnection.setRemoteDescription(new RTCSessionDescription(message.body));
|
||||||
@@ -3215,6 +3225,33 @@ class Taoyao extends RemoteClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统信息信令
|
||||||
|
*
|
||||||
|
* @returns 系统信息
|
||||||
|
*/
|
||||||
|
async systemInfo() {
|
||||||
|
return await this.request(protocol.buildMessage("system::info", {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重启系统信令
|
||||||
|
*
|
||||||
|
* @returns 重启系统
|
||||||
|
*/
|
||||||
|
async systemReboot() {
|
||||||
|
return await this.request(protocol.buildMessage("system::reboot", {}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭系统信令
|
||||||
|
*
|
||||||
|
* @returns 关闭系统
|
||||||
|
*/
|
||||||
|
async systemShutdown() {
|
||||||
|
return await this.request(protocol.buildMessage("system::shutdown", {}));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {*} session 会话
|
* @param {*} session 会话
|
||||||
* @param {*} sessionId 会话ID
|
* @param {*} sessionId 会话ID
|
||||||
@@ -3250,13 +3287,11 @@ class Taoyao extends RemoteClient {
|
|||||||
};
|
};
|
||||||
peerConnection.onicecandidate = event => {
|
peerConnection.onicecandidate = event => {
|
||||||
console.debug("会话媒体协商", event);
|
console.debug("会话媒体协商", event);
|
||||||
me.push(
|
me.push(protocol.buildMessage("session::exchange", {
|
||||||
protocol.buildMessage("session::exchange", {
|
type : "candidate",
|
||||||
type : "candidate",
|
sessionId : sessionId,
|
||||||
sessionId : sessionId,
|
candidate : event.candidate
|
||||||
candidate : event.candidate
|
}));
|
||||||
})
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
peerConnection.onnegotiationneeded = event => {
|
peerConnection.onnegotiationneeded = event => {
|
||||||
console.debug("会话媒体重新协商", event);
|
console.debug("会话媒体重新协商", event);
|
||||||
|
|||||||
@@ -35,24 +35,24 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
|||||||
)
|
)
|
||||||
public class MediaRouterRtpCapabilitiesProtocol extends ProtocolRoomAdapter {
|
public class MediaRouterRtpCapabilitiesProtocol extends ProtocolRoomAdapter {
|
||||||
|
|
||||||
public static final String SIGNAL = "media::router::rtp::capabilities";
|
public static final String SIGNAL = "media::router::rtp::capabilities";
|
||||||
|
|
||||||
public MediaRouterRtpCapabilitiesProtocol() {
|
public MediaRouterRtpCapabilitiesProtocol() {
|
||||||
super("路由RTP协商信令", SIGNAL);
|
super("路由RTP协商信令", SIGNAL);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean authenticate(Room room, Client client) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
protected boolean authenticate(Room room, Client client) {
|
||||||
if(clientType.mediaClient()) {
|
return true;
|
||||||
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),
|
"audio" : 是否需要声音(true|false),
|
||||||
"video" : 是否需要视频(true|false)
|
"video" : 是否需要视频(true|false)
|
||||||
}
|
}
|
||||||
""",
|
{
|
||||||
flow = {
|
"name" : "终端名称",
|
||||||
"终端->信令服务->终端",
|
"clientId" : "终端ID",
|
||||||
"终端=>信令服务->终端"
|
"sessionId": "会话ID"
|
||||||
}
|
}
|
||||||
|
""",
|
||||||
|
flow = "终端=>信令服务->终端"
|
||||||
)
|
)
|
||||||
public class SessionCallProtocol extends ProtocolSessionAdapter {
|
public class SessionCallProtocol extends ProtocolSessionAdapter {
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,10 @@ import com.acgist.taoyao.signal.protocol.ProtocolSessionAdapter;
|
|||||||
@Description(
|
@Description(
|
||||||
body = """
|
body = """
|
||||||
{
|
{
|
||||||
|
"sessionId": "会话ID"
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
flow = "终端->信令服务+)终端"
|
flow = "终端->信令服务->终端"
|
||||||
)
|
)
|
||||||
public class SessionCloseProtocol extends ProtocolSessionAdapter implements ApplicationListener<SessionCloseEvent> {
|
public class SessionCloseProtocol extends ProtocolSessionAdapter implements ApplicationListener<SessionCloseEvent> {
|
||||||
|
|
||||||
|
|||||||
@@ -25,22 +25,22 @@ import com.acgist.taoyao.signal.protocol.ProtocolSessionAdapter;
|
|||||||
""",
|
""",
|
||||||
body = """
|
body = """
|
||||||
{
|
{
|
||||||
"sdp": "sdp"
|
"sdp" : "sdp"
|
||||||
"type": "offer",
|
"type" : "offer",
|
||||||
"sessionId": "会话ID"
|
"sessionId": "会话ID"
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
"sdp": "sdp"
|
"sdp" : "sdp"
|
||||||
"type": "answer",
|
"type" : "answer",
|
||||||
"sessionId": "会话ID"
|
"sessionId": "会话ID"
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
"type": "candidate",
|
"type" : "candidate",
|
||||||
"sessionId": "会话ID",
|
"sessionId": "会话ID",
|
||||||
"candidate": {
|
"candidate": {
|
||||||
"sdpMid": "sdpMid",
|
"sdpMid" : "sdpMid",
|
||||||
"candidate": "candidate信息",
|
"candidate" : "candidate信息",
|
||||||
"sdpMLineIndex":sdpMLineIndex
|
"sdpMLineIndex": sdpMLineIndex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
|
|||||||
@@ -29,23 +29,24 @@ import lombok.Setter;
|
|||||||
{
|
{
|
||||||
"diskspace": [
|
"diskspace": [
|
||||||
{
|
{
|
||||||
"path": "存储路径",
|
"path" : "存储路径",
|
||||||
"free": 存储空闲,
|
"free" : 存储空闲,
|
||||||
"total": 存储总量
|
"total": 存储总量
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
],
|
],
|
||||||
"maxMemory": 最大能用内存,
|
"maxMemory" : 最大能用内存,
|
||||||
"freeMemory": 空闲内存,
|
"freeMemory" : 空闲内存,
|
||||||
"totalMemory": 已用内存,
|
"totalMemory" : 已用内存,
|
||||||
"osArch": "系统架构",
|
"osArch" : "系统架构",
|
||||||
"osName": "系统名称",
|
"osName" : "系统名称",
|
||||||
"osVersion": "系统版本",
|
"osVersion" : "系统版本",
|
||||||
"javaVmName": "虚拟机名称",
|
"javaVmName" : "虚拟机名称",
|
||||||
"javaVersion": "虚拟机版本",
|
"javaVersion" : "虚拟机版本",
|
||||||
"cpuProcessors": CPU核心数量
|
"cpuProcessors": CPU核心数量
|
||||||
}
|
}
|
||||||
"""
|
""",
|
||||||
|
flow = "终端=>信令服务"
|
||||||
)
|
)
|
||||||
public class SystemInfoProtocol extends ProtocolClientAdapter {
|
public class SystemInfoProtocol extends ProtocolClientAdapter {
|
||||||
|
|
||||||
@@ -82,7 +83,8 @@ public class SystemInfoProtocol extends ProtocolClientAdapter {
|
|||||||
info.put("javaVersion", System.getProperty("java.version"));
|
info.put("javaVersion", System.getProperty("java.version"));
|
||||||
info.put("cpuProcessors", runtime.availableProcessors());
|
info.put("cpuProcessors", runtime.availableProcessors());
|
||||||
// 响应
|
// 响应
|
||||||
client.push(this.build(info));
|
message.setBody(info);
|
||||||
|
client.push(message);
|
||||||
};
|
};
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@@ -111,10 +113,10 @@ public class SystemInfoProtocol extends ProtocolClientAdapter {
|
|||||||
private final String totalGracefully;
|
private final String totalGracefully;
|
||||||
|
|
||||||
public Diskspace(String path, Long free, Long total) {
|
public Diskspace(String path, Long free, Long total) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.free = free;
|
this.free = free;
|
||||||
this.total = total;
|
this.total = total;
|
||||||
this.freeGracefully = FileUtils.formatSize(free);
|
this.freeGracefully = FileUtils.formatSize(free);
|
||||||
this.totalGracefully = FileUtils.formatSize(total);
|
this.totalGracefully = FileUtils.formatSize(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,42 +21,43 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Description(
|
@Description(
|
||||||
flow = {
|
flow = {
|
||||||
"信令服务+)终端",
|
"信令服务+)终端",
|
||||||
"终端->信令服务+)终端"
|
"终端->信令服务+)终端",
|
||||||
|
"终端=>信令服务+)终端"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public class SystemRebootProtocol extends ProtocolClientAdapter {
|
public class SystemRebootProtocol extends ProtocolClientAdapter {
|
||||||
|
|
||||||
public static final String SIGNAL = "system::reboot";
|
public static final String SIGNAL = "system::reboot";
|
||||||
|
|
||||||
private final ScriptProperties scriptProperties;
|
private final ScriptProperties scriptProperties;
|
||||||
|
|
||||||
public SystemRebootProtocol(ScriptProperties scriptProperties) {
|
public SystemRebootProtocol(ScriptProperties scriptProperties) {
|
||||||
super("重启系统信令", SIGNAL);
|
super("重启系统信令", SIGNAL);
|
||||||
this.scriptProperties = scriptProperties;
|
this.scriptProperties = scriptProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||||
log.info("重启系统:{}", clientId);
|
log.info("重启系统:{}", clientId);
|
||||||
this.reboot(message);
|
this.reboot(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重启系统
|
* 重启系统
|
||||||
*/
|
*/
|
||||||
public void execute() {
|
public void execute() {
|
||||||
log.info("重启系统");
|
log.info("重启系统");
|
||||||
this.reboot(this.build());
|
this.reboot(this.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重启系统
|
* 重启系统
|
||||||
*
|
*
|
||||||
* @param message 消息
|
* @param message 消息
|
||||||
*/
|
*/
|
||||||
private void reboot(Message message) {
|
private void reboot(Message message) {
|
||||||
this.clientManager.broadcast(message);
|
this.clientManager.broadcast(message);
|
||||||
ScriptUtils.execute(this.scriptProperties.getSystemReboot());
|
ScriptUtils.execute(this.scriptProperties.getSystemReboot());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,42 +21,43 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
@Description(
|
@Description(
|
||||||
flow = {
|
flow = {
|
||||||
"信令服务+)终端",
|
"信令服务+)终端",
|
||||||
"终端->信令服务+)终端"
|
"终端->信令服务+)终端",
|
||||||
|
"终端=>信令服务+)终端"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
public class SystemShutdownProtocol extends ProtocolClientAdapter {
|
public class SystemShutdownProtocol extends ProtocolClientAdapter {
|
||||||
|
|
||||||
public static final String SIGNAL = "system::shutdown";
|
public static final String SIGNAL = "system::shutdown";
|
||||||
|
|
||||||
private final ScriptProperties scriptProperties;
|
private final ScriptProperties scriptProperties;
|
||||||
|
|
||||||
public SystemShutdownProtocol(ScriptProperties scriptProperties) {
|
public SystemShutdownProtocol(ScriptProperties scriptProperties) {
|
||||||
super("关闭系统信令", SIGNAL);
|
super("关闭系统信令", SIGNAL);
|
||||||
this.scriptProperties = scriptProperties;
|
this.scriptProperties = scriptProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
public void execute(String clientId, ClientType clientType, Client client, Message message, Map<String, Object> body) {
|
||||||
log.info("关闭系统:{}", clientId);
|
log.info("关闭系统:{}", clientId);
|
||||||
this.shutdown(message);
|
this.shutdown(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行命令信令
|
* 执行命令信令
|
||||||
*/
|
*/
|
||||||
public void execute() {
|
public void execute() {
|
||||||
log.info("关闭系统");
|
log.info("关闭系统");
|
||||||
this.shutdown(this.build());
|
this.shutdown(this.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭系统
|
* 关闭系统
|
||||||
*
|
*
|
||||||
* @param message 消息
|
* @param message 消息
|
||||||
*/
|
*/
|
||||||
private void shutdown(Message message) {
|
private void shutdown(Message message) {
|
||||||
this.clientManager.broadcast(message);
|
this.clientManager.broadcast(message);
|
||||||
ScriptUtils.execute(this.scriptProperties.getSystemShutdown());
|
ScriptUtils.execute(this.scriptProperties.getSystemShutdown());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user