snowflake/proxy/shims.coffee
Arlo Breault f3254e3402 Remove Modernizr dependency
And inline its only use site.
2019-05-08 11:23:49 -04:00

36 lines
948 B
CoffeeScript

###
WebRTC shims for multiple browsers.
###
if module?.exports
window = {}
location = ''
if not TESTING? or not TESTING
webrtc = require 'wrtc'
PeerConnection = webrtc.RTCPeerConnection
IceCandidate = webrtc.RTCIceCandidate
SessionDescription = webrtc.RTCSessionDescription
WebSocket = require 'ws'
{ XMLHttpRequest } = require 'xmlhttprequest'
process.nextTick () -> init true
else
window = this
location = window.location.search.substr(1)
PeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection ||
window.webkitRTCPeerConnection
IceCandidate = window.RTCIceCandidate || window.mozRTCIceCandidate
SessionDescription = window.RTCSessionDescription ||
window.mozRTCSessionDescription
if typeof PeerConnection isnt 'function'
console.log 'webrtc feature not detected. shutting down'
return
WebSocket = window.WebSocket
XMLHttpRequest = window.XMLHttpRequest