提交 8be35aee authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Improve transport closure

上级 49089984
......@@ -636,14 +636,13 @@ class Peer extends EnhancedEventEmitter
this._sendNotification(method, data2);
});
// TODO: Do we need this? The C++ Transport closes all its Producers and
// Consumers, and the client side gets producer.on('unhandled'), there is
// no need to close/destroy its local Producer.
// On Transport closure close the Producer.
// On closure, the worker Transport closes all its Producers and Consumers,
// and the client side gets producer.on('unhandled'), so there is no need
// to close/destroy its local Producer.
transport.on('@close', () =>
{
if (!producer.closed)
producer.close();
producer.close(undefined, false);
});
this.emit('@newproducer', producer);
......
......@@ -119,6 +119,8 @@ class Room extends EnhancedEventEmitter
if (this._closed)
return Promise.reject(new errors.InvalidStateError('Room closed'));
// TODO: Should we aggregate Peers info?
return this._channel.request('router.dump', this._internal)
.then((data) =>
{
......
......@@ -226,23 +226,34 @@ namespace RTC
this->iceServer->Destroy();
for (auto socket : this->udpSockets)
{
socket->Destroy();
}
this->udpSockets.clear();
for (auto server : this->tcpServers)
{
server->Destroy();
}
this->tcpServers.clear();
this->selectedTuple = nullptr;
// Close all the handled Producers and Consumers.
for (auto& producer : this->producers)
// Close all the handled Producers.
for (auto it = this->producers.begin(); it != this->producers.end();)
{
auto* producer = *it;
it = this->producers.erase(it);
producer->Destroy();
}
for (auto& consumer : this->consumers)
// Close all the handled Consumers.
for (auto it = this->consumers.begin(); it != this->consumers.end();)
{
auto* consumer = *it;
it = this->consumers.erase(it);
consumer->Destroy();
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论