[*] 日常优化
This commit is contained in:
@@ -4,7 +4,6 @@ import java.io.Closeable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作接口
|
* 操作接口
|
||||||
* 所有操作直接发出事件
|
|
||||||
*
|
*
|
||||||
* @author acgist
|
* @author acgist
|
||||||
*/
|
*/
|
||||||
@@ -12,6 +11,7 @@ public interface Operator extends Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭资源
|
* 关闭资源
|
||||||
|
* 推荐使用事件实现
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
void close();
|
void close();
|
||||||
@@ -23,11 +23,13 @@ public interface Operator extends Closeable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 暂停资源
|
* 暂停资源
|
||||||
|
* 推荐使用事件实现
|
||||||
*/
|
*/
|
||||||
void pause();
|
void pause();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 恢复资源
|
* 恢复资源
|
||||||
|
* 推荐使用事件实现
|
||||||
*/
|
*/
|
||||||
void resume();
|
void resume();
|
||||||
|
|
||||||
|
|||||||
@@ -353,5 +353,90 @@ public class Room extends OperatorAdapter {
|
|||||||
this.dataProducers.values().stream().filter(v -> !this.clients.containsValue(v.getProducerClient())).forEach(DataProducer::close);
|
this.dataProducers.values().stream().filter(v -> !this.clients.containsValue(v.getProducerClient())).forEach(DataProducer::close);
|
||||||
this.transports.values().stream().filter(v -> !this.clients.containsKey(v.getClient())).forEach(Transport::close);
|
this.transports.values().stream().filter(v -> !this.clients.containsKey(v.getClient())).forEach(Transport::close);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除消费者
|
||||||
|
*
|
||||||
|
* @param consumerId 消费者ID
|
||||||
|
*/
|
||||||
|
public void removeConsumer(String consumerId) {
|
||||||
|
final Consumer consumer = this.consumers.remove(consumerId);
|
||||||
|
if(consumer == null) {
|
||||||
|
log.info("移除消费者:{}", consumerId);
|
||||||
|
} else {
|
||||||
|
log.info("移除消费者:{} - {}", consumerId, consumer.getStreamId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除生产者
|
||||||
|
*
|
||||||
|
* @param producerId 生产者ID
|
||||||
|
*/
|
||||||
|
public void removeProducer(String producerId) {
|
||||||
|
final Producer producer = this.producers.get(producerId);
|
||||||
|
if(producer == null) {
|
||||||
|
log.info("移除生产者:{}", producerId);
|
||||||
|
} else {
|
||||||
|
log.info("移除生产者:{} - {}", producerId, producer.getStreamId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除数据消费者
|
||||||
|
*
|
||||||
|
* @param consumerId 数据消费者ID
|
||||||
|
*/
|
||||||
|
public void removeDataConsumer(String consumerId) {
|
||||||
|
final DataConsumer consumer = this.dataConsumers.get(consumerId);
|
||||||
|
if(consumer == null) {
|
||||||
|
log.info("移除数据消费者:{}", consumerId);
|
||||||
|
} else {
|
||||||
|
log.info("移除数据消费者:{} - {}", consumerId, consumer.getStreamId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除数据生产者
|
||||||
|
*
|
||||||
|
* @param producerId 数据生产者ID
|
||||||
|
*/
|
||||||
|
public void removeDataProducer(String producerId) {
|
||||||
|
final DataProducer producer = this.dataProducers.get(producerId);
|
||||||
|
if(producer == null) {
|
||||||
|
log.info("移除数据生产者:{}", producerId);
|
||||||
|
} else {
|
||||||
|
log.info("移除数据生产者:{} - {}", producerId, producer.getStreamId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除终端
|
||||||
|
*
|
||||||
|
* @param clientId 终端ID
|
||||||
|
*/
|
||||||
|
public void removeClient(String clientId) {
|
||||||
|
final ClientWrapper client = this.clientWrapper(clientId);
|
||||||
|
if(client == null) {
|
||||||
|
log.info("移除终端:{}", clientId);
|
||||||
|
} else {
|
||||||
|
this.clients.remove(client.getClient());
|
||||||
|
log.info("移除终端:{}", clientId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除通道
|
||||||
|
*
|
||||||
|
* @param transportId 通道ID
|
||||||
|
*/
|
||||||
|
public void removeTransport(String transportId) {
|
||||||
|
final Transport transport = this.transports.get(transportId);
|
||||||
|
if(transport == null) {
|
||||||
|
log.info("移除通道:{}", transportId);
|
||||||
|
} else {
|
||||||
|
log.info("移除通道:{}", transportId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user