[*] 日常优化
This commit is contained in:
@@ -901,7 +901,7 @@ class Taoyao {
|
|||||||
});
|
});
|
||||||
consumer.observer.on("close", () => {
|
consumer.observer.on("close", () => {
|
||||||
if(room.consumers.delete(consumer.id)) {
|
if(room.consumers.delete(consumer.id)) {
|
||||||
console.info("消费者关闭", consumer.id, streamId);
|
console.debug("消费者关闭", consumer.id, streamId);
|
||||||
me.push(protocol.buildMessage("media::consumer::close", {
|
me.push(protocol.buildMessage("media::consumer::close", {
|
||||||
roomId,
|
roomId,
|
||||||
consumerId: consumer.id
|
consumerId: consumer.id
|
||||||
@@ -958,20 +958,22 @@ class Taoyao {
|
|||||||
/**
|
/**
|
||||||
* 关闭消费者信令
|
* 关闭消费者信令
|
||||||
*
|
*
|
||||||
* @param {*} message 消息
|
* @param {*} message 信令消息
|
||||||
* @param {*} body 消息主体
|
* @param {*} body 消息主体
|
||||||
*/
|
*/
|
||||||
async mediaConsumerClose(message, body) {
|
async mediaConsumerClose(message, body) {
|
||||||
const me = this;
|
const {
|
||||||
const { roomId, consumerId } = body;
|
roomId,
|
||||||
const room = me.rooms.get(roomId);
|
consumerId
|
||||||
|
} = body;
|
||||||
|
const room = this.rooms.get(roomId);
|
||||||
const consumer = room?.consumers.get(consumerId);
|
const consumer = room?.consumers.get(consumerId);
|
||||||
if(consumer) {
|
if(!consumer) {
|
||||||
console.info("关闭消费者", consumerId);
|
console.debug("关闭消费者(消费者无效)", roomId, consumerId);
|
||||||
await consumer.close();
|
return;
|
||||||
} else {
|
|
||||||
console.debug("关闭消费者无效(无效)", consumerId);
|
|
||||||
}
|
}
|
||||||
|
console.debug("关闭消费者", consumerId);
|
||||||
|
await consumer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂停消费者信令
|
* 暂停消费者信令
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class MediaConsumerCloseProtocol extends ProtocolRoomAdapter implements A
|
|||||||
final Room room = event.getRoom();
|
final Room room = event.getRoom();
|
||||||
final Client mediaClient = event.getMediaClient();
|
final Client mediaClient = event.getMediaClient();
|
||||||
final Map<String, Object> body = Map.of(
|
final Map<String, Object> body = Map.of(
|
||||||
Constant.ROOM_ID, room.getRoomId(),
|
Constant.ROOM_ID, room.getRoomId(),
|
||||||
Constant.CONSUMER_ID, event.getConsumerId()
|
Constant.CONSUMER_ID, event.getConsumerId()
|
||||||
);
|
);
|
||||||
mediaClient.push(this.build(body));
|
mediaClient.push(this.build(body));
|
||||||
|
|||||||
Reference in New Issue
Block a user