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

Node: cleanup.

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