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

Node: cleanup.

上级 bcd8d8ea
...@@ -15,11 +15,8 @@ class Peer extends EventEmitter ...@@ -15,11 +15,8 @@ class Peer extends EventEmitter
super(); super();
// Room identificator // Store internal data
this._roomId = internal.roomId; this._internal = internal;
// Peer identificator
this._peerId = internal.peerId;
// Channel instance // Channel instance
this._channel = channel; this._channel = channel;
...@@ -58,11 +55,7 @@ class Peer extends EventEmitter ...@@ -58,11 +55,7 @@ class Peer extends EventEmitter
if (!dontSendChannel) if (!dontSendChannel)
{ {
let internal = let internal = this._internal;
{
roomId : this._roomId,
peerId : this._peerId
};
// Send Channel request // Send Channel request
this._channel.request('peer.close', internal) this._channel.request('peer.close', internal)
...@@ -86,11 +79,7 @@ class Peer extends EventEmitter ...@@ -86,11 +79,7 @@ class Peer extends EventEmitter
if (this._closed) if (this._closed)
return Promise.reject(errors.Closed('peer closed')); return Promise.reject(errors.Closed('peer closed'));
let internal = let internal = this._internal;
{
roomId : this._roomId,
peerId : this._peerId
};
return this._channel.request('peer.dump', internal) return this._channel.request('peer.dump', internal)
.then((data) => .then((data) =>
...@@ -123,8 +112,8 @@ class Peer extends EventEmitter ...@@ -123,8 +112,8 @@ class Peer extends EventEmitter
let internal = let internal =
{ {
roomId : this._roomId, roomId : this._internal.roomId,
peerId : this._peerId, peerId : this._internal.peerId,
transportId : utils.randomNumber() transportId : utils.randomNumber()
}; };
......
...@@ -14,8 +14,8 @@ class Room extends EventEmitter ...@@ -14,8 +14,8 @@ class Room extends EventEmitter
super(); super();
// Room identificator // Store internal data
this._roomId = internal.roomId; this._internal = internal;
// Channel instance // Channel instance
this._channel = channel; this._channel = channel;
...@@ -57,10 +57,7 @@ class Room extends EventEmitter ...@@ -57,10 +57,7 @@ class Room extends EventEmitter
if (!dontSendChannel) if (!dontSendChannel)
{ {
let internal = let internal = this._internal;
{
roomId : this._roomId
};
// Send Channel request // Send Channel request
this._channel.request('room.close', internal) this._channel.request('room.close', internal)
...@@ -84,10 +81,7 @@ class Room extends EventEmitter ...@@ -84,10 +81,7 @@ class Room extends EventEmitter
if (this._closed) if (this._closed)
return Promise.reject(errors.Closed('room closed')); return Promise.reject(errors.Closed('room closed'));
let internal = let internal = this._internal;
{
roomId : this._roomId
};
return this._channel.request('room.dump', internal) return this._channel.request('room.dump', internal)
.then((data) => .then((data) =>
...@@ -124,7 +118,7 @@ class Room extends EventEmitter ...@@ -124,7 +118,7 @@ class Room extends EventEmitter
let internal = let internal =
{ {
roomId : this._roomId, roomId : this._internal.roomId,
peerId : peerId peerId : peerId
}; };
...@@ -136,7 +130,10 @@ class Room extends EventEmitter ...@@ -136,7 +130,10 @@ class Room extends EventEmitter
peer.on('close', () => this._peers.delete(peerId)); peer.on('close', () => this._peers.delete(peerId));
this._channel.request('room.createPeer', internal) this._channel.request('room.createPeer', internal)
.then(() => logger.debug('"room.createPeer" request succeeded')) .then(() =>
{
logger.debug('"room.createPeer" request succeeded');
})
.catch((error) => .catch((error) =>
{ {
logger.error('"room.createPeer" request failed [status:%s, error:"%s"]', error.status, error.message); logger.error('"room.createPeer" request failed [status:%s, error:"%s"]', error.status, error.message);
......
...@@ -14,14 +14,8 @@ class Transport extends EventEmitter ...@@ -14,14 +14,8 @@ class Transport extends EventEmitter
super(); super();
// Room identificator // Store internal data
this._roomId = internal.roomId; this._internal = internal;
// Peer identificator
this._peerId = internal.peerId;
// Transport identificator
this._transportId = internal.transportId;
// Transport data provided by the worker // Transport data provided by the worker
this._data = data; this._data = data;
...@@ -77,12 +71,7 @@ class Transport extends EventEmitter ...@@ -77,12 +71,7 @@ class Transport extends EventEmitter
if (!dontSendChannel) if (!dontSendChannel)
{ {
let internal = let internal = this._internal;
{
roomId : this._roomId,
peerId : this._peerId,
transportId : this._transportId
};
// Send Channel request // Send Channel request
this._channel.request('transport.close', internal) this._channel.request('transport.close', internal)
...@@ -106,12 +95,7 @@ class Transport extends EventEmitter ...@@ -106,12 +95,7 @@ class Transport extends EventEmitter
if (this._closed) if (this._closed)
return Promise.reject(errors.Closed('transport closed')); return Promise.reject(errors.Closed('transport closed'));
let internal = let internal = this._internal;
{
roomId : this._roomId,
peerId : this._peerId,
transportId : this._transportId
};
return this._channel.request('transport.dump', internal) return this._channel.request('transport.dump', internal)
.then((data) => .then((data) =>
...@@ -140,12 +124,7 @@ class Transport extends EventEmitter ...@@ -140,12 +124,7 @@ class Transport extends EventEmitter
if (this._closed) if (this._closed)
return Promise.reject(errors.Closed('transport closed')); return Promise.reject(errors.Closed('transport closed'));
let internal = let internal = this._internal;
{
roomId : this._roomId,
peerId : this._peerId,
transportId : this._transportId
};
// Send Channel request // Send Channel request
return this._channel.request('transport.setRemoteDtlsParameters', internal, options) return this._channel.request('transport.setRemoteDtlsParameters', internal, options)
...@@ -154,6 +133,8 @@ class Transport extends EventEmitter ...@@ -154,6 +133,8 @@ class Transport extends EventEmitter
logger.debug('"transport.setRemoteDtlsParameters" request succeeded'); logger.debug('"transport.setRemoteDtlsParameters" request succeeded');
// TODO: Handle content of data and append it to this._data. // TODO: Handle content of data and append it to this._data.
// TODO: do we want to return data? It is better to document that
// at this point the DTLS related stuff is available via API
return data; return data;
}) })
...@@ -178,10 +159,10 @@ class Transport extends EventEmitter ...@@ -178,10 +159,10 @@ class Transport extends EventEmitter
let internal = let internal =
{ {
roomId : this._roomId, roomId : this._internal.roomId,
peerId : this._peerId, peerId : this._internal.peerId,
transportId : utils.randomNumber(), transportId : utils.randomNumber(),
rtpTransportId : this._transportId rtpTransportId : this._internal.transportId
}; };
return this._channel.request('peer.createAssociatedTransport', internal) return this._channel.request('peer.createAssociatedTransport', internal)
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论