[*] 日常优化
This commit is contained in:
@@ -165,7 +165,7 @@ export default {
|
||||
async loadList() {
|
||||
this.rooms = await this.taoyao.roomList();
|
||||
this.medias = await this.taoyao.mediaList();
|
||||
this.clients = await this.taoyao.clientList();
|
||||
this.clients = await this.taoyao.mediaClientList();
|
||||
},
|
||||
async sessionCall() {
|
||||
this.taoyao.sessionCall(this.room.callClientId);
|
||||
|
||||
@@ -777,6 +777,12 @@ class Taoyao extends RemoteClient {
|
||||
case "client::broadcast":
|
||||
me.defaultClientBroadcast(message);
|
||||
break;
|
||||
case "client::offline":
|
||||
me.defaultClientOffline(message);
|
||||
break;
|
||||
case "client::online":
|
||||
me.defaultClientOnline(message);
|
||||
break;
|
||||
case "client::reboot":
|
||||
me.defaultClientReboot(message);
|
||||
break;
|
||||
@@ -1043,41 +1049,10 @@ class Taoyao extends RemoteClient {
|
||||
/**
|
||||
* 关闭终端信令
|
||||
*/
|
||||
clientClose() {
|
||||
async clientClose() {
|
||||
const me = this;
|
||||
me.push(protocol.buildMessage("client::close", {}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns 媒体服务列表
|
||||
*/
|
||||
async mediaList() {
|
||||
const response = await this.request(protocol.buildMessage("client::list", {
|
||||
clientType: "MEDIA"
|
||||
}));
|
||||
return response.body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns 媒体终端列表
|
||||
*/
|
||||
async mediaClientList() {
|
||||
const response = await this.request(protocol.buildMessage("client::list", {}));
|
||||
return response.body.filter(v => {
|
||||
return v.clientType === "WEB" || v.clientType === "CAMERA" || v.clientType === "MOBILE";
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} clientType 终端类型(默认所有)
|
||||
*
|
||||
* @returns 终端列表
|
||||
*/
|
||||
async clientList(clientType) {
|
||||
const response = await this.request(protocol.buildMessage("client::list", {
|
||||
clientType
|
||||
}));
|
||||
return response.body;
|
||||
await me.request(protocol.buildMessage("client::close", {}));
|
||||
me.closeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1114,7 +1089,10 @@ class Taoyao extends RemoteClient {
|
||||
ideal: video.frameRate,
|
||||
max : media.maxFrameRate,
|
||||
};
|
||||
me.options = Object.keys(media.videos).map(key => ({value: key, label: media.videos[key].resolution}));
|
||||
me.options = Object.keys(media.videos).map(key => ({
|
||||
value: key,
|
||||
label: media.videos[key].resolution
|
||||
}));
|
||||
me.mediaConfig = media;
|
||||
me.webrtcConfig = webrtc;
|
||||
console.debug(
|
||||
@@ -1127,13 +1105,63 @@ class Taoyao extends RemoteClient {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns 媒体服务列表
|
||||
*/
|
||||
async mediaList() {
|
||||
const response = await this.request(protocol.buildMessage("client::list", {
|
||||
clientType: "MEDIA"
|
||||
}));
|
||||
return response.body;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns 媒体终端列表
|
||||
*/
|
||||
async mediaClientList() {
|
||||
const response = await this.request(protocol.buildMessage("client::list", {}));
|
||||
return response.body.filter(v => {
|
||||
return v.clientType === "WEB" || v.clientType === "CAMERA" || v.clientType === "MOBILE";
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} clientType 终端类型(可选)
|
||||
*
|
||||
* @returns 终端列表
|
||||
*/
|
||||
async clientList(clientType) {
|
||||
const response = await this.request(protocol.buildMessage("client::list", {
|
||||
clientType
|
||||
}));
|
||||
return response.body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端下线信令
|
||||
*
|
||||
* @param {*} message 信令消息
|
||||
*/
|
||||
defaultClientOffline(message) {
|
||||
console.debug("终端下线", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 终端上线信令
|
||||
*
|
||||
* @param {*} message 信令消息
|
||||
*/
|
||||
defaultClientOnline(message) {
|
||||
console.debug("终端上线", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重启终端信令
|
||||
*
|
||||
* @param {*} message 信令消息
|
||||
*/
|
||||
defaultClientReboot(message) {
|
||||
console.info("重启终端");
|
||||
console.info("重启终端", message);
|
||||
location.reload();
|
||||
}
|
||||
|
||||
@@ -1143,7 +1171,7 @@ class Taoyao extends RemoteClient {
|
||||
* @param {*} message 消息
|
||||
*/
|
||||
defaultClientShutdown(message) {
|
||||
console.info("关闭终端");
|
||||
console.info("关闭终端", message);
|
||||
window.close();
|
||||
}
|
||||
|
||||
@@ -1837,10 +1865,11 @@ class Taoyao extends RemoteClient {
|
||||
* @param {*} message 消息
|
||||
*/
|
||||
defaultPlatformError(message) {
|
||||
const me = this;
|
||||
const { code } = message;
|
||||
if (code === "3401") {
|
||||
// 没有授权直接关闭
|
||||
signalChannel.close();
|
||||
me.closeAll();
|
||||
} else {
|
||||
console.warn("平台异常", message);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.event.ClientEventAdapter;
|
||||
|
||||
/**
|
||||
* 终端关闭事件
|
||||
* 关闭终端事件
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.acgist.taoyao.signal.event.room;
|
||||
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.event.ClientEventAdapter;
|
||||
|
||||
/**
|
||||
* 媒体服务注册事件
|
||||
* 需要重新创建房间
|
||||
*
|
||||
* 媒体服务掉线两种方案
|
||||
*
|
||||
* 1. 注册相同名称媒体服务,注册成功之后通知媒体服务终端重新连接。
|
||||
* 2. 自动转移媒体服务终端到个新的媒体服务,然后通知媒体服务终端重新连接。
|
||||
*
|
||||
* 本项目采用第一种方案
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class MediaServerRegisterEvent extends ClientEventAdapter {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MediaServerRegisterEvent(Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.acgist.taoyao.signal.event.room;
|
||||
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.event.ClientEventAdapter;
|
||||
|
||||
/**
|
||||
* 创建房间事件
|
||||
*
|
||||
* @author acgist
|
||||
*/
|
||||
public class RoomCreateEvent extends ClientEventAdapter {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public RoomCreateEvent(Client client) {
|
||||
super(client);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,8 +29,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
如果终端意外掉线,需要自己实现重连逻辑。
|
||||
""",
|
||||
flow = {
|
||||
"终端->信令服务->终端",
|
||||
"终端-[关闭终端]>信令服务-[终端下线])终端",
|
||||
"终端=>信令服务->终端",
|
||||
"终端=>信令服务-[终端下线])终端",
|
||||
"终端-[连接断开]>信令服务-[终端下线])终端"
|
||||
}
|
||||
)
|
||||
|
||||
@@ -23,7 +23,10 @@ import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter;
|
||||
"clientId": "下线终端ID"
|
||||
}
|
||||
""",
|
||||
flow = "终端-[终端关闭]>信令服务-)终端"
|
||||
flow = {
|
||||
"终端=[关闭终端]>信令服务-[终端下线])终端",
|
||||
"终端-[连接断开]>信令服务-[终端下线])终端"
|
||||
}
|
||||
)
|
||||
public class ClientOfflineProtocol extends ProtocolClientAdapter implements ApplicationListener<ClientOfflineEvent> {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import com.acgist.taoyao.signal.client.ClientStatus;
|
||||
import com.acgist.taoyao.signal.client.ClientType;
|
||||
import com.acgist.taoyao.signal.event.client.ClientConfigEvent;
|
||||
import com.acgist.taoyao.signal.event.client.ClientOnlineEvent;
|
||||
import com.acgist.taoyao.signal.event.room.RoomCreateEvent;
|
||||
import com.acgist.taoyao.signal.event.room.MediaServerRegisterEvent;
|
||||
import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter;
|
||||
import com.acgist.taoyao.signal.service.SecurityService;
|
||||
|
||||
@@ -99,7 +99,7 @@ public class ClientRegisterProtocol extends ProtocolClientAdapter {
|
||||
this.publishEvent(new ClientOnlineEvent(client));
|
||||
// 媒体服务注册:创建房间事件
|
||||
if(clientType.mediaServer()) {
|
||||
this.publishEvent(new RoomCreateEvent(client));
|
||||
this.publishEvent(new MediaServerRegisterEvent(client));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import com.acgist.taoyao.boot.model.Message;
|
||||
import com.acgist.taoyao.boot.utils.MapUtils;
|
||||
import com.acgist.taoyao.signal.client.Client;
|
||||
import com.acgist.taoyao.signal.client.ClientType;
|
||||
import com.acgist.taoyao.signal.event.room.RoomCreateEvent;
|
||||
import com.acgist.taoyao.signal.event.room.MediaServerRegisterEvent;
|
||||
import com.acgist.taoyao.signal.party.room.Room;
|
||||
import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter;
|
||||
|
||||
@@ -41,7 +41,7 @@ import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter;
|
||||
},
|
||||
flow = "终端->信令服务->媒体服务->信令服务+)终端"
|
||||
)
|
||||
public class RoomCreateProtocol extends ProtocolClientAdapter implements ApplicationListener<RoomCreateEvent> {
|
||||
public class RoomCreateProtocol extends ProtocolClientAdapter implements ApplicationListener<MediaServerRegisterEvent> {
|
||||
|
||||
public static final String SIGNAL = "room::create";
|
||||
|
||||
@@ -51,8 +51,9 @@ public class RoomCreateProtocol extends ProtocolClientAdapter implements Applica
|
||||
|
||||
@Async
|
||||
@Override
|
||||
public void onApplicationEvent(RoomCreateEvent event) {
|
||||
public void onApplicationEvent(MediaServerRegisterEvent event) {
|
||||
this.roomManager.recreate(event.getClient(), this.build());
|
||||
// TODO:通知
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user