@testrtc/watchrtc-sdk
Advanced tools
Comparing version 1.26.3 to 1.26.5
@@ -106,3 +106,3 @@ "use strict"; | ||
var getWSConnectionData = function (rtcApiKey) { | ||
var getWSConnectionData = function (rtcApiKey, overriddenWsUrl) { | ||
const localUrl = "ws://localhost:9101"; | ||
@@ -115,3 +115,3 @@ const stagingUrl = "wss://watchrtc-staging2.testrtc.com"; | ||
return { | ||
url: localUrl, | ||
url: overriddenWsUrl || localUrl, | ||
apiKey: splitted[1], | ||
@@ -121,3 +121,3 @@ }; | ||
return { | ||
url: stagingUrl, | ||
url: overriddenWsUrl || stagingUrl, | ||
apiKey: splitted[1], | ||
@@ -127,3 +127,3 @@ }; | ||
return { | ||
url: productionUrl, | ||
url: overriddenWsUrl || productionUrl, | ||
apiKey: splitted[1], | ||
@@ -133,3 +133,3 @@ }; | ||
return { | ||
url: productionUrl, | ||
url: overriddenWsUrl || productionUrl, | ||
apiKey: splitted[0], | ||
@@ -165,41 +165,69 @@ }; | ||
if (!wsConnectCalled) { | ||
const wsConnectionData = getWSConnectionData(config.rtcApiKey); | ||
traceWS.connect(wsConnectionData.url + "?apiKey=" + wsConnectionData.apiKey, function ( | ||
data | ||
) { | ||
trace("watchrtc", id, Object.assign(config, data)); | ||
var canConnect = true; | ||
if (!config) { | ||
console.error("watchRTC SDK. watchrtc config is required."); | ||
canConnect = false; | ||
} | ||
if (!config.watchrtc) { | ||
console.error("watchRTC SDK. watchrtc config is required."); | ||
canConnect = false; | ||
} else if (!config.watchrtc.rtcApiKey) { | ||
console.error("watchRTC SDK. watchrtc.rtcApiKey is required."); | ||
canConnect = false; | ||
} else if (!config.watchrtc.rtcRoomId) { | ||
console.error("watchRTC SDK. watchrtc.rtcRoomId is required."); | ||
canConnect = false; | ||
} else if (!config.watchrtc.rtcPeerId) { | ||
console.error("watchRTC SDK. watchrtc.rtcPeerId is required."); | ||
canConnect = false; | ||
} | ||
if (canConnect) { | ||
const wsConnectionData = getWSConnectionData( | ||
config.watchrtc.rtcApiKey, | ||
config.watchrtc.wsUrl | ||
); | ||
if (!isEdge) { | ||
window.clearInterval(interval); | ||
interval = window.setInterval(function () { | ||
if (pc.signalingState === "closed") { | ||
window.clearInterval(interval); | ||
return; | ||
} | ||
getStats(); | ||
}, data.interval); | ||
} | ||
}); | ||
wsConnectCalled = true; | ||
traceWS.connect(wsConnectionData.url + "?apiKey=" + wsConnectionData.apiKey, function ( | ||
data | ||
) { | ||
trace("watchrtc", id, Object.assign(config.watchrtc, data)); | ||
if (!isEdge) { | ||
window.clearInterval(interval); | ||
interval = window.setInterval(function () { | ||
if (pc.signalingState === "closed") { | ||
window.clearInterval(interval); | ||
return; | ||
} | ||
getStats(); | ||
}, data.interval); | ||
} | ||
}); | ||
wsConnectCalled = true; | ||
} | ||
} | ||
if (!config) { | ||
config = { nullConfig: true }; | ||
var configCopy = JSON.parse(JSON.stringify(config)); // deepcopy | ||
if (!configCopy) { | ||
configCopy = { nullConfig: true }; | ||
} | ||
config = JSON.parse(JSON.stringify(config)); // deepcopy | ||
// don't log credentials | ||
((config && config.iceServers) || []).forEach(function (server) { | ||
((configCopy && configCopy.iceServers) || []).forEach(function (server) { | ||
delete server.credential; | ||
}); | ||
if (configCopy.watchrtc) { | ||
delete configCopy.watchrtc; | ||
} | ||
if (isFirefox) { | ||
config.browserType = "moz"; | ||
configCopy.browserType = "moz"; | ||
} else if (isEdge) { | ||
config.browserType = "edge"; | ||
configCopy.browserType = "edge"; | ||
} else { | ||
config.browserType = "webkit"; | ||
configCopy.browserType = "webkit"; | ||
} | ||
trace("create", id, config); | ||
trace("create", id, configCopy); | ||
// TODO: do we want to log constraints here? They are chrome-proprietary. | ||
@@ -206,0 +234,0 @@ // http://stackoverflow.com/questions/31003928/what-do-each-of-these-experimental-goog-rtcpeerconnectionconstraints-do |
{ | ||
"name": "@testrtc/watchrtc-sdk", | ||
"version": "1.26.3", | ||
"version": "1.26.5", | ||
"description": "gather WebRTC API traces and statistics", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,7 +23,7 @@ Low-level logging on peerconnection API calls and periodic getStats calls for analytics/debugging purposes | ||
..., | ||
rtcApiKey: "watchrtc api key", | ||
rtcClientId: "your client identifier", | ||
rtcPeerId: "identifier for the current peer", | ||
rtcSessionId: "identifier for the session", | ||
wsUrl: "websocket url", | ||
watchrtc:{ | ||
rtcApiKey: "watchrtc api key", | ||
rtcRoomId: "identifier for the session" | ||
rtcPeerId: "identifier for the current peer", | ||
} | ||
}); | ||
@@ -30,0 +30,0 @@ ``` |
21238
591