[*] 日常优化
This commit is contained in:
@@ -374,8 +374,11 @@ class Taoyao {
|
|||||||
on(message) {
|
on(message) {
|
||||||
const me = this;
|
const me = this;
|
||||||
// 解构
|
// 解构
|
||||||
const { header, body } = message;
|
const { code, header, body } = message;
|
||||||
const { id, signal } = header;
|
const { id, signal } = header;
|
||||||
|
if(code !== "0000") {
|
||||||
|
console.warn("信令错误", message);
|
||||||
|
}
|
||||||
// 请求回调
|
// 请求回调
|
||||||
if (me.callbackMapping.has(id)) {
|
if (me.callbackMapping.has(id)) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -721,8 +721,11 @@ class Taoyao extends RemoteClient {
|
|||||||
*/
|
*/
|
||||||
async on(message) {
|
async on(message) {
|
||||||
const me = this;
|
const me = this;
|
||||||
const { header, body } = message;
|
const { code, header, body } = message;
|
||||||
const { id } = header;
|
const { id, signal } = header;
|
||||||
|
if(code !== "0000") {
|
||||||
|
console.warn("信令错误", message);
|
||||||
|
}
|
||||||
// 请求回调
|
// 请求回调
|
||||||
if (me.callbackMapping.has(id)) {
|
if (me.callbackMapping.has(id)) {
|
||||||
try {
|
try {
|
||||||
@@ -2262,19 +2265,6 @@ class Taoyao extends RemoteClient {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {*} clientId 终端ID
|
|
||||||
*
|
|
||||||
* @returns 终端所有ID
|
|
||||||
*/
|
|
||||||
async roomClientListId(clientId) {
|
|
||||||
const response = await this.request(protocol.buildMessage("room::client::list::id", {
|
|
||||||
roomId : this.roomId,
|
|
||||||
clientId: clientId
|
|
||||||
}));
|
|
||||||
return response.body;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 媒体回调
|
* 媒体回调
|
||||||
*
|
*
|
||||||
@@ -2818,6 +2808,21 @@ class Taoyao extends RemoteClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 房间终端ID集合信令
|
||||||
|
*
|
||||||
|
* @param {*} clientId 终端ID
|
||||||
|
*
|
||||||
|
* @returns 房间终端ID集合
|
||||||
|
*/
|
||||||
|
async roomClientListId(clientId) {
|
||||||
|
const response = await this.request(protocol.buildMessage("room::client::list::id", {
|
||||||
|
roomId : this.roomId,
|
||||||
|
clientId: clientId
|
||||||
|
}));
|
||||||
|
return response.body;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 房间终端列表信令
|
* 房间终端列表信令
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
|||||||
...
|
...
|
||||||
}
|
}
|
||||||
""",
|
""",
|
||||||
flow = "终端=>信令服务->终端"
|
flow = "终端=>信令服务"
|
||||||
)
|
)
|
||||||
public class RoomClientListIdProtocol extends ProtocolRoomAdapter {
|
public class RoomClientListIdProtocol extends ProtocolRoomAdapter {
|
||||||
|
|
||||||
@@ -48,11 +48,13 @@ public class RoomClientListIdProtocol extends ProtocolRoomAdapter {
|
|||||||
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map<String, Object> body) {
|
||||||
final String queryClientId = MapUtils.get(body, Constant.CLIENT_ID, clientId);
|
final String queryClientId = MapUtils.get(body, Constant.CLIENT_ID, clientId);
|
||||||
final ClientWrapper clientWrapper = room.clientWrapper(queryClientId);
|
final ClientWrapper clientWrapper = room.clientWrapper(queryClientId);
|
||||||
final RoomClientId roomClientId = new RoomClientId();
|
final RoomClientId roomClientId = new RoomClientId();
|
||||||
roomClientId.setRoomId(room.getRoomId());
|
roomClientId.setRoomId(room.getRoomId());
|
||||||
roomClientId.setClientId(queryClientId);
|
roomClientId.setClientId(queryClientId);
|
||||||
|
// 数据生产者和消费者
|
||||||
clientWrapper.getDataProducers().keySet().forEach(roomClientId.getDataProducers()::add);
|
clientWrapper.getDataProducers().keySet().forEach(roomClientId.getDataProducers()::add);
|
||||||
clientWrapper.getDataConsumers().keySet().forEach(roomClientId.getDataConsumers()::add);
|
clientWrapper.getDataConsumers().keySet().forEach(roomClientId.getDataConsumers()::add);
|
||||||
|
// 媒体生产者
|
||||||
clientWrapper.getProducers().values().stream()
|
clientWrapper.getProducers().values().stream()
|
||||||
.filter(v -> v.getKind() == Kind.AUDIO)
|
.filter(v -> v.getKind() == Kind.AUDIO)
|
||||||
.map(Producer::getProducerId)
|
.map(Producer::getProducerId)
|
||||||
@@ -61,6 +63,7 @@ public class RoomClientListIdProtocol extends ProtocolRoomAdapter {
|
|||||||
.filter(v -> v.getKind() == Kind.VIDEO)
|
.filter(v -> v.getKind() == Kind.VIDEO)
|
||||||
.map(Producer::getProducerId)
|
.map(Producer::getProducerId)
|
||||||
.forEach(roomClientId.getVideoProducers()::add);
|
.forEach(roomClientId.getVideoProducers()::add);
|
||||||
|
// 媒体生产者
|
||||||
clientWrapper.getConsumers().values().stream()
|
clientWrapper.getConsumers().values().stream()
|
||||||
.filter(v -> v.getKind() == Kind.AUDIO)
|
.filter(v -> v.getKind() == Kind.AUDIO)
|
||||||
.map(Consumer::getConsumerId)
|
.map(Consumer::getConsumerId)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter;
|
|||||||
"""
|
"""
|
||||||
},
|
},
|
||||||
flow = {
|
flow = {
|
||||||
"终端=>信令服务->终端",
|
"终端=>信令服务",
|
||||||
"终端=[进入房间]>信令服务->终端",
|
"终端=[进入房间]>信令服务->终端",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user