electron-webrtc
Advanced tools
Comparing version 0.2.9 to 0.2.10
{ | ||
"name": "electron-webrtc", | ||
"version": "0.2.9", | ||
"version": "0.2.10", | ||
"description": "Use WebRTC in Node.js via a hidden Electron process", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -18,2 +18,4 @@ 'use strict' | ||
this._dataChannels = new Map() | ||
this._offer = null | ||
this._answer = null | ||
this.iceConnectionState = 'new' | ||
@@ -61,7 +63,26 @@ this.iceGatheringState = 'new' | ||
} | ||
send(id, { | ||
type: 'icecandidate', | ||
event: event, | ||
iceGatheringState: pc.iceGatheringState | ||
var offer, answer | ||
function sendEvent () { | ||
send(id, { | ||
type: 'icecandidate', | ||
event: event, | ||
iceGatheringState: pc.iceGatheringState, | ||
offer: offer ? offer.toJSON() : null, | ||
answer: answer ? answer.toJSON() : null | ||
}) | ||
} | ||
pc.createOffer(function (o) { | ||
offer = o | ||
if (answer != null) sendEvent() | ||
}, function () { | ||
offer = false | ||
if (answer != null) sendEvent() | ||
}) | ||
pc.createAnswer(function (a) { | ||
answer = a | ||
if (offer != null) sendEvent() | ||
}, function () { | ||
answer = false | ||
if (offer != null) sendEvent() | ||
}) | ||
} | ||
@@ -140,2 +161,8 @@ pc.oniceconnectionstatechange = function (e) { | ||
this.iceGatheringState = message.iceGatheringState | ||
if (message.offer) { | ||
this._offer = Object.assign(this._offer || {}, message.offer) | ||
} | ||
if (message.answer) { | ||
this._answer = Object.assign(this._answer || {}, message.answer) | ||
} | ||
break | ||
@@ -167,6 +194,10 @@ | ||
createOffer (cb, errCb, options) { | ||
if (this._offer) return cb(this._offer) | ||
return this._callRemote( | ||
'createOffer', | ||
`onSuccess, onFailure, ${JSON.stringify(options)}`, | ||
cb, errCb | ||
(offer) => { | ||
this._offer = offer | ||
cb(offer) | ||
}, errCb | ||
) | ||
@@ -176,6 +207,10 @@ } | ||
createAnswer (cb, errCb, options) { | ||
if (this._answer) return cb(this._answer) | ||
return this._callRemote( | ||
'createAnswer', | ||
`onSuccess, onFailure, ${JSON.stringify(options)}`, | ||
cb, errCb | ||
(offer) => { | ||
this._answer = offer | ||
cb(offer) | ||
}, errCb | ||
) | ||
@@ -182,0 +217,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
10033389
14
884