webrtc-conductor
Advanced tools
Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "webrtc-conductor", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A lightweight module to allow for efficient management, creation, reuse and destruction of WebRTC DataChannels.", | ||
@@ -5,0 +5,0 @@ "main": "src/wrtc-res-man.js", |
@@ -86,2 +86,6 @@ # WebRTC Conductor [![Build Status](https://travis-ci.org/FelixMcFelix/webrtc-conductor.svg)](https://travis-ci.org/FelixMcFelix/webrtc-conductor) [![Code Climate](https://codeclimate.com/github/FelixMcFelix/webrtc-conductor/badges/gpa.svg)](https://codeclimate.com/github/FelixMcFelix/webrtc-conductor) | ||
### 0.1.4 | ||
* Fixes #4, where configs did not correctly merge. This allows serverside applications to work as intended now. | ||
* Fixes #2, #3. These bugs both resulted from incorrect handling of resources and promises. | ||
### 0.1.3 | ||
@@ -88,0 +92,0 @@ * Addition of simple .close() method on connections. This closes a connection for real, and is not intelligently managed. |
@@ -50,4 +50,2 @@ "use strict"; | ||
console.log("Received Channel from other partner.") | ||
console.log(trConn.dataChannels.__default) | ||
console.log(evt.channel) | ||
trConn.registerDataChannel(evt.channel); | ||
@@ -119,12 +117,12 @@ } | ||
}, | ||
_mergeConfig = config => { | ||
_mergeConfig = (config1, config2)=>{ | ||
let out = {}; | ||
for(var propName in defaultConfig) | ||
if(defaultConfig.hasOwnProperty(propName)) | ||
out[propName] = defaultConfig[propName]; | ||
for(var propName in config1) | ||
if(config1.hasOwnProperty(propName)) | ||
out[propName] = config1[propName]; | ||
for(var propName in config) | ||
if(config.hasOwnProperty(propName) && (out[propName] === null || out[propName] === undefined)) | ||
out[propName] = config[propName]; | ||
for(var propName in config2) | ||
if(config2.hasOwnProperty(propName)) | ||
out[propName] = config2[propName]; | ||
@@ -166,37 +164,38 @@ return out; | ||
// let dataChan = look.connection.createDataChannel("__default", null); | ||
let dataChan = {}; | ||
let ready = channel._ready | ||
.then(result => { | ||
if(result){ | ||
dataChan = look.addDataChannel("__default"); | ||
return look.connection.createOffer({}); | ||
prom = new Promise((resolve,reject)=>{ | ||
let dataChan = {}; | ||
let ready = channel._ready | ||
.then(result => { | ||
if(result){ | ||
dataChan = look.addDataChannel("__default"); | ||
return look.connection.createOffer({}); | ||
} | ||
else | ||
return new Promise((res,rej)=>{rej("Channel failed to become ready for connection or is not allowing outbound offers.");}); | ||
}) | ||
.then(result => { | ||
return look.connection.setLocalDescription(result); | ||
}) | ||
.then( | ||
result => { | ||
channel.send(id, enums.MSG_SDP_OFFER, look.connection.localDescription); | ||
return true; | ||
}, | ||
reason => { | ||
console.log(reason); | ||
return false; | ||
} | ||
); | ||
console.log(ready); | ||
ready.then(val => { | ||
if(val){ | ||
dataChan.onopen = () => resolve(look); | ||
dataChan.onerror = err => reject(err); | ||
} else { | ||
reject("Cannot create new data channel - connection channel is not alllowing outbound offers.") | ||
} | ||
else | ||
return new Promise((res,rej)=>{rej("Channel failed to become ready for connection or is not allowing outbound offers.");}); | ||
}) | ||
.then(result => { | ||
return look.connection.setLocalDescription(result); | ||
}) | ||
.then( | ||
result => { | ||
channel.send(id, enums.MSG_SDP_OFFER, look.connection.localDescription); | ||
return true; | ||
}, | ||
reason => { | ||
console.log(reason); | ||
return false; | ||
} | ||
); | ||
prom = new Promise((resolve,reject)=>{ | ||
// dataChan.then( | ||
// result => resolve(look), | ||
// reason => reject(reason) | ||
// ); | ||
// if(ready){ | ||
dataChan.onopen = () => resolve(look); | ||
dataChan.onerror = err => reject(err); | ||
// } | ||
}); | ||
@@ -243,3 +242,2 @@ | ||
console.log("ICE candidate picked up by manager."); | ||
console.log(data); | ||
target.connection.addIceCandidate(new this.config.rtc_facade.RTCIceCandidate(data)) | ||
@@ -300,3 +298,6 @@ .then( | ||
this._connectionRegistry[newName] = this._connectionRegistry[oldName] | ||
let item = this._connectionRegistry[oldName]; | ||
this._connectionRegistry[newName] = item; | ||
item.id = newName; | ||
delete this._connectionRegistry[oldName]; | ||
@@ -308,5 +309,4 @@ } | ||
// Initialisation code | ||
this.config = _mergeConfig(defaultConfig, config); | ||
this.config = _mergeConfig(config); | ||
if(!_validateConfig(this.config)) | ||
@@ -313,0 +313,0 @@ throw new TypeError("An 'rtc_facade', 'rtc_config' and 'channel' must be defined for WebRTC to be used."); |
@@ -132,5 +132,14 @@ var expect = require("chai").expect, | ||
}); | ||
it("should ensure that the id field of the connection is changed", () => { | ||
var val = {test: "prop"}; | ||
resManInst._connectionRegistry["initial"] = val; | ||
resManInst.renameConnection("initial", "final"); | ||
expect(resManInst._connectionRegistry["final"].id).to.equal("final"); | ||
}); | ||
}); | ||
describe("Active Connections", () => { | ||
// describe("Active Connections", () => { | ||
// var wrtc, manager; | ||
@@ -137,0 +146,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38637
776
104