[*] 日常优化

This commit is contained in:
acgist
2023-10-07 07:38:45 +08:00
parent c60bb0902e
commit 993ed9ed1d
3 changed files with 44 additions and 45 deletions

View File

@@ -901,7 +901,7 @@ class Taoyao {
});
consumer.observer.on("close", () => {
if(room.consumers.delete(consumer.id)) {
console.info("消费者关闭", consumer.id, streamId);
console.debug("消费者关闭", consumer.id, streamId);
me.push(protocol.buildMessage("media::consumer::close", {
roomId,
consumerId: consumer.id
@@ -958,20 +958,22 @@ class Taoyao {
/**
* 关闭消费者信令
*
* @param {*} message 消息
* @param {*} message 信令消息
* @param {*} body 消息主体
*/
async mediaConsumerClose(message, body) {
const me = this;
const { roomId, consumerId } = body;
const room = me.rooms.get(roomId);
const {
roomId,
consumerId
} = body;
const room = this.rooms.get(roomId);
const consumer = room?.consumers.get(consumerId);
if(consumer) {
console.info("关闭消费者", consumerId);
await consumer.close();
} else {
console.debug("关闭消费者无效(无效)", consumerId);
if(!consumer) {
console.debug("关闭消费者(消费者无效)", roomId, consumerId);
return;
}
console.debug("关闭消费者", consumerId);
await consumer.close();
}
/**

View File

@@ -1521,40 +1521,6 @@ class Taoyao extends RemoteClient {
}
}
/**
* 关闭消费者信令
*
* @param {*} consumerId 消费者ID
*/
mediaConsumerClose(consumerId) {
const me = this;
me.push(protocol.buildMessage("media::consumer::close", {
roomId : me.roomId,
consumerId: consumerId,
}));
}
/**
* 关闭消费者信令
*
* @param {*} message 信令消息
* @param {*} body 消息主体
*/
defaultMediaConsumerClose(message, body) {
const me = this;
const {
roomId,
consumerId
} = body;
const consumer = me.consumers.get(consumerId);
if (consumer) {
console.debug("关闭消费者", consumerId);
consumer.close();
} else {
console.debug("关闭消费者无效", consumerId);
}
}
/**
* 消费媒体信令
*
@@ -1662,6 +1628,37 @@ class Taoyao extends RemoteClient {
}
}
/**
* 关闭消费者信令
*
* @param {*} consumerId 消费者ID
*/
mediaConsumerClose(consumerId) {
this.push(protocol.buildMessage("media::consumer::close", {
consumerId,
roomId: this.roomId,
}));
}
/**
* 关闭消费者信令
*
* @param {*} message 信令消息
* @param {*} body 消息主体
*/
defaultMediaConsumerClose(message, body) {
const {
consumerId
} = body;
const consumer = this.consumers.get(consumerId);
if(!consumer) {
console.debug("关闭消费者(消费者无效)", consumerId);
return;
}
console.debug("关闭消费者", consumerId);
consumer.close();
}
/**
* 暂停消费者信令
*

View File

@@ -54,7 +54,7 @@ public class MediaConsumerCloseProtocol extends ProtocolRoomAdapter implements A
final Room room = event.getRoom();
final Client mediaClient = event.getMediaClient();
final Map<String, Object> body = Map.of(
Constant.ROOM_ID, room.getRoomId(),
Constant.ROOM_ID, room.getRoomId(),
Constant.CONSUMER_ID, event.getConsumerId()
);
mediaClient.push(this.build(body));