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

Improve transport closure

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