docs: update README with improved Docker commands and add credits section
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m33s
All checks were successful
Build and Push Docker Image / build (push) Successful in 2m33s
feat: enhance WebRTC stats collection by logging connection state changes
This commit is contained in:
@@ -40,6 +40,9 @@ class WebrtcInternalExporter {
|
||||
pc.iceCandidateErrors = [];
|
||||
this.peerConnections.set(id, pc);
|
||||
pc.addEventListener("connectionstatechange", () => {
|
||||
log(`connectionStateChange: ${pc.connectionState}`);
|
||||
this.collectAndPostSingleStat(id);
|
||||
|
||||
if (pc.connectionState === "closed") {
|
||||
this.peerConnections.delete(id);
|
||||
}
|
||||
@@ -83,7 +86,7 @@ class WebrtcInternalExporter {
|
||||
}
|
||||
|
||||
async collectAndPostSingleStat(id) {
|
||||
const stats = await this.collectStats(id, this.collectAndPostSingleStat);
|
||||
const stats = await this.collectStats(id);
|
||||
if (Object.keys(stats).length === 0 || !stats) return;
|
||||
|
||||
window.postMessage(
|
||||
@@ -98,9 +101,10 @@ class WebrtcInternalExporter {
|
||||
async collectAllStats() {
|
||||
const stats = [];
|
||||
|
||||
for (const [id, pc] of this.peerConnections) {
|
||||
for (const [id] of this.peerConnections) {
|
||||
if (this.url && this.enabled) {
|
||||
const pcStats = await this.collectStats(id, pc);
|
||||
const pcStats = await this.collectStats(id);
|
||||
if (Object.keys(pcStats).length === 0 || !pcStats) continue;
|
||||
stats.push(pcStats);
|
||||
}
|
||||
}
|
||||
@@ -120,16 +124,12 @@ class WebrtcInternalExporter {
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
* @param {RTCPeerConnection} pc
|
||||
* @param {Function} binding
|
||||
*/
|
||||
async collectStats(id, pc, binding) {
|
||||
var completeStats = {};
|
||||
async collectStats(id) {
|
||||
var pc = this.peerConnections.get(id);
|
||||
if (!pc) return;
|
||||
|
||||
if (!pc) {
|
||||
pc = this.peerConnections.get(id);
|
||||
if (!pc) return;
|
||||
}
|
||||
var completeStats = {};
|
||||
|
||||
if (this.url && this.enabled) {
|
||||
try {
|
||||
@@ -157,10 +157,6 @@ class WebrtcInternalExporter {
|
||||
|
||||
if (pc.connectionState === "closed") {
|
||||
this.peerConnections.delete(id);
|
||||
} else {
|
||||
if (binding) {
|
||||
setTimeout(binding.bind(this), this.updateInterval, id);
|
||||
}
|
||||
}
|
||||
|
||||
return completeStats;
|
||||
|
Reference in New Issue
Block a user