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

Node: Improve internal doc in classes.

Node: Manually fire closure events when close() is called.
上级 767e7e76
...@@ -17,6 +17,8 @@ class Peer extends EventEmitter ...@@ -17,6 +17,8 @@ class Peer extends EventEmitter
this.setMaxListeners(Infinity); this.setMaxListeners(Infinity);
// Store internal data // Store internal data
// - .roomId
// - .peerId
this._internal = internal; this._internal = internal;
// Channel instance // Channel instance
...@@ -59,8 +61,8 @@ class Peer extends EventEmitter ...@@ -59,8 +61,8 @@ class Peer extends EventEmitter
this._closed = true; this._closed = true;
// Remove notification subscriptions (wait a bit so closure events arrive) // Remove notification subscriptions
setTimeout(() => this._channel.removeAllListeners(this._internal.peerId), 1000); this._channel.removeAllListeners(this._internal.peerId);
// Close every Transport // Close every Transport
this._transports.forEach((transport) => transport.close(undefined, true)); this._transports.forEach((transport) => transport.close(undefined, true));
......
...@@ -17,6 +17,7 @@ class Room extends EventEmitter ...@@ -17,6 +17,7 @@ class Room extends EventEmitter
this.setMaxListeners(Infinity); this.setMaxListeners(Infinity);
// Store internal data // Store internal data
// - .roomId
this._internal = internal; this._internal = internal;
// Channel instance // Channel instance
......
...@@ -16,9 +16,33 @@ class Transport extends EventEmitter ...@@ -16,9 +16,33 @@ class Transport extends EventEmitter
this.setMaxListeners(Infinity); this.setMaxListeners(Infinity);
// Store internal data // Store internal data
// - .roomId
// - .peerId
// - .transportId
this._internal = internal; this._internal = internal;
// Transport data provided by the worker // Transport data provided by the worker
// - .iceComponent
// - .iceLocalParameters
// - .usernameFragment
// - .password
// - .iceLocalCandidates []
// - .foundation
// - .priority
// - .ip
// - .port
// - .type
// - .protocol
// - .tcpType
// - .dtlsLocalParameters
// - .fingerprints
// - .sha-1
// - .sha-224
// - .sha-256
// - .sha-384
// - .sha-512
// - .role
// - .dtlsState
this._data = data; this._data = data;
// Channel instance // Channel instance
...@@ -91,8 +115,16 @@ class Transport extends EventEmitter ...@@ -91,8 +115,16 @@ class Transport extends EventEmitter
this._closed = true; this._closed = true;
// Remove notification subscriptions (wait a bit so closure events arrive) // Remove notification subscriptions
setTimeout(() => this._channel.removeAllListeners(this._internal.transportId), 1000); this._channel.removeAllListeners(this._internal.transportId);
// We won't receive events anymore, so be nice and manually update
// some fields and emit events before firing 'close'
if (this._data.dtlsState !== 'closed')
{
this._data.dtlsState = 'closed';
this.emit('dtlsstatechange', { dtlsState: 'closed' });
}
if (!dontSendChannel) if (!dontSendChannel)
{ {
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论