rtcpeerconnection
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "rtcpeerconnection", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "A tiny browser module that gives normalizes and simplifies the API for WebRTC peer connections.", | ||
@@ -23,3 +23,6 @@ "main": "rtcpeerconnection.js", | ||
"browserify": "2.x" | ||
}, | ||
"jshintConfig": { | ||
"expr": true | ||
} | ||
} |
@@ -363,2 +363,37 @@ (function(e){if("function"==typeof bootstrap)bootstrap("peerconnection",e);else if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makePeerConnection=e}else"undefined"!=typeof window?window.PeerConnection=e():global.PeerConnection=e()})(function(){var define,ses,bootstrap,module,exports; | ||
// Create a data channel spec reference: | ||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelInit | ||
PeerConnection.prototype.createDataChannel = function (name, opts) { | ||
opts || (opts = {}); | ||
var reliable = !!opts.reliable; | ||
var protocol = opts.protocol || 'text/plain'; | ||
var negotiated = !!(opts.negotiated || opts.preset); | ||
var settings; | ||
var channel; | ||
// firefox is a bit more finnicky | ||
if (webrtc.prefix === 'moz') { | ||
if (reliable) { | ||
settings = { | ||
protocol: protocol, | ||
preset: negotiated, | ||
stream: name | ||
}; | ||
} else { | ||
settings = {}; | ||
} | ||
channel = this.pc.createDataChannel(name, settings); | ||
channel.binaryType = 'blob'; | ||
} else { | ||
if (reliable) { | ||
settings = { | ||
reliable: true | ||
}; | ||
} else { | ||
settings = {reliable: false}; | ||
} | ||
channel = this.pc.createDataChannel(name, settings); | ||
} | ||
return channel; | ||
}; | ||
module.exports = PeerConnection; | ||
@@ -365,0 +400,0 @@ |
@@ -185,2 +185,37 @@ var WildEmitter = require('wildemitter'); | ||
// Create a data channel spec reference: | ||
// http://dev.w3.org/2011/webrtc/editor/webrtc.html#idl-def-RTCDataChannelInit | ||
PeerConnection.prototype.createDataChannel = function (name, opts) { | ||
opts || (opts = {}); | ||
var reliable = !!opts.reliable; | ||
var protocol = opts.protocol || 'text/plain'; | ||
var negotiated = !!(opts.negotiated || opts.preset); | ||
var settings; | ||
var channel; | ||
// firefox is a bit more finnicky | ||
if (webrtc.prefix === 'moz') { | ||
if (reliable) { | ||
settings = { | ||
protocol: protocol, | ||
preset: negotiated, | ||
stream: name | ||
}; | ||
} else { | ||
settings = {}; | ||
} | ||
channel = this.pc.createDataChannel(name, settings); | ||
channel.binaryType = 'blob'; | ||
} else { | ||
if (reliable) { | ||
settings = { | ||
reliable: true | ||
}; | ||
} else { | ||
settings = {reliable: false}; | ||
} | ||
channel = this.pc.createDataChannel(name, settings); | ||
} | ||
return channel; | ||
}; | ||
module.exports = PeerConnection; |
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
25452
546