@observertc/observer-js 1.0.1-c3edea3.0 → 1.0.1-c9e7581.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/ObservedCall.d.ts +43 -7
- package/lib/ObservedCall.d.ts.map +1 -1
- package/lib/ObservedCall.js +142 -14
- package/lib/ObservedCallEventMonitor.d.ts +104 -0
- package/lib/ObservedCallEventMonitor.d.ts.map +1 -0
- package/lib/ObservedCallEventMonitor.js +314 -0
- package/lib/ObservedCallSummary.d.ts +18 -0
- package/lib/ObservedCallSummary.d.ts.map +1 -0
- package/lib/ObservedClient.d.ts +71 -11
- package/lib/ObservedClient.d.ts.map +1 -1
- package/lib/ObservedClient.js +509 -72
- package/lib/ObservedClientEventMonitor.d.ts +89 -0
- package/lib/ObservedClientEventMonitor.d.ts.map +1 -0
- package/lib/ObservedClientEventMonitor.js +247 -0
- package/lib/ObservedClientSummary.d.ts +23 -0
- package/lib/ObservedClientSummary.d.ts.map +1 -0
- package/lib/ObservedClientSummary.js +2 -0
- package/lib/ObservedDataChannel.d.ts +6 -0
- package/lib/ObservedDataChannel.d.ts.map +1 -1
- package/lib/ObservedDataChannel.js +30 -0
- package/lib/ObservedIceCandidatePair.d.ts +6 -1
- package/lib/ObservedIceCandidatePair.d.ts.map +1 -1
- package/lib/ObservedIceCandidatePair.js +45 -1
- package/lib/ObservedIceTransport.d.ts +4 -0
- package/lib/ObservedIceTransport.d.ts.map +1 -1
- package/lib/ObservedIceTransport.js +28 -0
- package/lib/ObservedInboundTrack.d.ts +3 -0
- package/lib/ObservedInboundTrack.d.ts.map +1 -1
- package/lib/ObservedInboundTrack.js +3 -0
- package/lib/ObservedOutboundTrack.d.ts +3 -0
- package/lib/ObservedOutboundTrack.d.ts.map +1 -1
- package/lib/ObservedOutboundTrack.js +3 -0
- package/lib/ObservedPeerConnection.d.ts +36 -2
- package/lib/ObservedPeerConnection.d.ts.map +1 -1
- package/lib/ObservedPeerConnection.js +184 -29
- package/lib/ObservedTURN.d.ts +31 -0
- package/lib/ObservedTURN.d.ts.map +1 -0
- package/lib/ObservedTURN.js +58 -0
- package/lib/ObservedTurnServer.d.ts +25 -0
- package/lib/ObservedTurnServer.d.ts.map +1 -0
- package/lib/ObservedTurnServer.js +59 -0
- package/lib/Observer.d.ts +43 -22
- package/lib/Observer.d.ts.map +1 -1
- package/lib/Observer.js +126 -40
- package/lib/ObserverEventMonitor.d.ts +138 -0
- package/lib/ObserverEventMonitor.d.ts.map +1 -0
- package/lib/ObserverEventMonitor.js +433 -0
- package/lib/ObserverSummary.d.ts +13 -0
- package/lib/ObserverSummary.d.ts.map +1 -0
- package/lib/ObserverSummary.js +2 -0
- package/lib/common/utils.d.ts +2 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +11 -3
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -1
- package/lib/schema/ClientEventTypes.d.ts +228 -0
- package/lib/schema/ClientEventTypes.d.ts.map +1 -0
- package/lib/schema/ClientEventTypes.js +41 -0
- package/lib/schema/{metaTypes.d.ts → ClientMetaTypes.d.ts} +2 -2
- package/lib/schema/ClientMetaTypes.d.ts.map +1 -0
- package/lib/schema/ClientMetaTypes.js +16 -0
- package/lib/schema/ClientSample.d.ts +1 -1
- package/lib/schema/ClientSample.d.ts.map +1 -1
- package/lib/updaters/CallUpdater.d.ts.map +1 -0
- package/lib/updaters/CallUpdater.js +2 -0
- package/lib/updaters/ObserverUpdater.d.ts +5 -0
- package/lib/updaters/ObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/ObserverUpdater.js +2 -0
- package/lib/updaters/OnAllCallObserverUpdater.d.ts +15 -0
- package/lib/updaters/OnAllCallObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAllCallObserverUpdater.js +50 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts +15 -0
- package/lib/updaters/OnAllClientCallUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAllClientCallUpdater.js +53 -0
- package/lib/updaters/OnAnyCallObserverUpdater.d.ts +12 -0
- package/lib/updaters/OnAnyCallObserverUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAnyCallObserverUpdater.js +37 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts +12 -0
- package/lib/updaters/OnAnyClientCallUpdater.d.ts.map +1 -0
- package/lib/updaters/OnAnyClientCallUpdater.js +36 -0
- package/lib/updaters/OnIntervalUpdater.d.ts +10 -0
- package/lib/updaters/OnIntervalUpdater.d.ts.map +1 -0
- package/lib/updaters/OnIntervalUpdater.js +17 -0
- package/lib/updaters/Updater.d.ts +6 -0
- package/lib/updaters/Updater.d.ts.map +1 -0
- package/lib/updaters/Updater.js +2 -0
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts +25 -0
- package/lib/utils/MediasoupRemoteTrackResolver.d.ts.map +1 -0
- package/lib/utils/MediasoupRemoteTrackResolver.js +110 -0
- package/package.json +1 -1
- package/src/ObservedCall.ts +222 -17
- package/src/ObservedCallEventMonitor.ts +392 -0
- package/src/ObservedCallSummary.ts +22 -0
- package/src/ObservedClient.ts +608 -79
- package/src/ObservedClientEventMonitor.ts +301 -0
- package/src/ObservedClientSummary.ts +24 -0
- package/src/ObservedDataChannel.ts +32 -0
- package/src/ObservedIceCandidatePair.ts +44 -2
- package/src/ObservedIceTransport.ts +29 -0
- package/src/ObservedInboundTrack.ts +5 -0
- package/src/ObservedOutboundTrack.ts +5 -0
- package/src/ObservedPeerConnection.ts +219 -46
- package/src/ObservedTURN.ts +86 -0
- package/src/ObservedTurnServer.ts +72 -0
- package/src/Observer.ts +179 -64
- package/src/ObserverEventMonitor.ts +551 -0
- package/src/ObserverSummary.ts +15 -0
- package/src/common/utils.ts +12 -2
- package/src/index.ts +6 -1
- package/src/schema/ClientEventTypes.ts +280 -0
- package/src/schema/{metaTypes.ts → ClientMetaTypes.ts} +1 -1
- package/src/schema/ClientSample.ts +1 -1
- package/src/updaters/ObserverUpdater.ts +5 -0
- package/src/updaters/OnAllCallObserverUpdater.ts +59 -0
- package/src/updaters/OnAllClientCallUpdater.ts +61 -0
- package/src/updaters/OnAnyCallObserverUpdater.ts +41 -0
- package/src/updaters/OnAnyClientCallUpdater.ts +39 -0
- package/src/updaters/OnIntervalUpdater.ts +19 -0
- package/src/updaters/Updater.ts +5 -0
- package/src/utils/MediasoupRemoteTrackResolver.ts +155 -0
- package/tsconfig.json +1 -1
- package/lib/schema/eventTypes.d.ts +0 -33
- package/lib/schema/eventTypes.d.ts.map +0 -1
- package/lib/schema/eventTypes.js +0 -38
- package/lib/schema/metaTypes.d.ts.map +0 -1
- package/lib/schema/metaTypes.js +0 -16
- package/lib/utils/CallUpdater.d.ts.map +0 -1
- package/lib/utils/OnAllClientCallUpdater.d.ts +0 -16
- package/lib/utils/OnAllClientCallUpdater.d.ts.map +0 -1
- package/lib/utils/OnAllClientCallUpdater.js +0 -58
- package/lib/utils/onAnyClientCallUpdater.d.ts +0 -14
- package/lib/utils/onAnyClientCallUpdater.d.ts.map +0 -1
- package/lib/utils/onAnyClientCallUpdater.js +0 -51
- package/src/schema/eventTypes.ts +0 -36
- package/src/utils/OnAllClientCallUpdater.ts +0 -68
- package/src/utils/onAnyClientCallUpdater.ts +0 -59
- /package/lib/{utils/CallUpdater.js → ObservedCallSummary.js} +0 -0
- /package/lib/{utils → updaters}/CallUpdater.d.ts +0 -0
- /package/src/{utils → updaters}/CallUpdater.ts +0 -0
package/lib/ObservedClient.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.ObservedClient = void 0;
|
|
|
4
4
|
const events_1 = require("events");
|
|
5
5
|
const ObservedPeerConnection_1 = require("./ObservedPeerConnection");
|
|
6
6
|
const logger_1 = require("./common/logger");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const ClientEventTypes_1 = require("./schema/ClientEventTypes");
|
|
8
|
+
const ClientMetaTypes_1 = require("./schema/ClientMetaTypes");
|
|
9
9
|
const utils_1 = require("./common/utils");
|
|
10
10
|
const Detectors_1 = require("./detectors/Detectors");
|
|
11
11
|
const logger = (0, logger_1.createLogger)('ObservedClient');
|
|
@@ -25,6 +25,8 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
25
25
|
closed = false;
|
|
26
26
|
joinedAt;
|
|
27
27
|
leftAt;
|
|
28
|
+
closedAt;
|
|
29
|
+
lastSampleTimestamp;
|
|
28
30
|
// the timestamp of the CLIENT_JOINED event
|
|
29
31
|
operationSystem;
|
|
30
32
|
engine;
|
|
@@ -32,43 +34,73 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
32
34
|
browser;
|
|
33
35
|
mediaConstraints = [];
|
|
34
36
|
usingTURN = false;
|
|
37
|
+
usingTCP = false;
|
|
35
38
|
availableOutgoingBitrate = 0;
|
|
36
39
|
availableIncomingBitrate = 0;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
totalInboundPacketsLost = 0;
|
|
41
|
+
totalInboundPacketsReceived = 0;
|
|
42
|
+
totalOutboundPacketsSent = 0;
|
|
43
|
+
totalDataChannelBytesSent = 0;
|
|
44
|
+
totalDataChannelBytesReceived = 0;
|
|
45
|
+
totalDataChannelMessagesSent = 0;
|
|
46
|
+
totalDataChannelMessagesReceived = 0;
|
|
47
|
+
totalReceivedAudioBytes = 0;
|
|
48
|
+
totalReceivedVideoBytes = 0;
|
|
49
|
+
totalSentAudioBytes = 0;
|
|
50
|
+
totalSentVideoBytes = 0;
|
|
51
|
+
totalSentBytes = 0;
|
|
52
|
+
totalReceivedBytes = 0;
|
|
53
|
+
deltaReceivedAudioBytes = 0;
|
|
54
|
+
deltaReceivedVideoBytes = 0;
|
|
55
|
+
deltaSentAudioBytes = 0;
|
|
56
|
+
deltaSentVideoBytes = 0;
|
|
57
|
+
deltaDataChannelBytesSent = 0;
|
|
58
|
+
deltaDataChannelBytesReceived = 0;
|
|
59
|
+
deltaDataChannelMessagesSent = 0;
|
|
60
|
+
deltaDataChannelMessagesReceived = 0;
|
|
61
|
+
deltaInboundPacketsLost = 0;
|
|
62
|
+
deltaInboundPacketsReceived = 0;
|
|
63
|
+
deltaOutboundPacketsSent = 0;
|
|
64
|
+
deltaTransportSentBytes = 0;
|
|
65
|
+
deltaTransportReceivedBytes = 0;
|
|
66
|
+
deltaRttLt50Measurements = 0;
|
|
67
|
+
deltaRttLt150Measurements = 0;
|
|
68
|
+
deltaRttLt300Measurements = 0;
|
|
69
|
+
deltaRttGtOrEq300Measurements = 0;
|
|
70
|
+
currentMaxRttInMs;
|
|
71
|
+
currentMinRttInMs;
|
|
72
|
+
currentAvgRttInMs;
|
|
73
|
+
sendingAudioBitrate = 0;
|
|
74
|
+
sendingVideoBitrate = 0;
|
|
75
|
+
receivingAudioBitrate = 0;
|
|
76
|
+
receivingVideoBitrate = 0;
|
|
77
|
+
numberOfInboundRtpStreams = 0;
|
|
78
|
+
numberOfInbundTracks = 0;
|
|
79
|
+
numberOfOutboundRtpStreams = 0;
|
|
80
|
+
numberOfOutboundTracks = 0;
|
|
81
|
+
numberOfDataChannels = 0;
|
|
82
|
+
totalRttLt50Measurements = 0;
|
|
83
|
+
totalRttLt150Measurements = 0;
|
|
84
|
+
totalRttLt300Measurements = 0;
|
|
85
|
+
totalRttGtOrEq300Measurements = 0;
|
|
86
|
+
deltaNumberOfIssues = 0;
|
|
87
|
+
totalScoreSum = 0;
|
|
88
|
+
numberOfScoreMeasurements = 0;
|
|
89
|
+
totalNumberOfIssues = 0;
|
|
62
90
|
mediaDevices = [];
|
|
63
91
|
issues = [];
|
|
92
|
+
_injections = {};
|
|
64
93
|
constructor(settings, call) {
|
|
65
94
|
super();
|
|
66
95
|
this.call = call;
|
|
67
96
|
this.setMaxListeners(Infinity);
|
|
68
97
|
this.clientId = settings.clientId;
|
|
69
|
-
this.appData = settings.appData;
|
|
98
|
+
this.appData = settings.appData ?? {};
|
|
70
99
|
this.detectors = new Detectors_1.Detectors();
|
|
71
100
|
}
|
|
101
|
+
get numberOfPeerConnections() {
|
|
102
|
+
return this.observedPeerConnections.size;
|
|
103
|
+
}
|
|
72
104
|
get score() {
|
|
73
105
|
return this.calculatedScore.value;
|
|
74
106
|
}
|
|
@@ -77,39 +109,170 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
77
109
|
return;
|
|
78
110
|
this.closed = true;
|
|
79
111
|
Array.from(this.observedPeerConnections.values()).forEach((peerConnection) => peerConnection.close());
|
|
112
|
+
if (!this.leftAt) {
|
|
113
|
+
this.leftAt = this.lastSampleTimestamp;
|
|
114
|
+
if (this.leftAt) {
|
|
115
|
+
this.emit('left');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
this.closedAt = Date.now();
|
|
80
119
|
this.emit('close');
|
|
81
120
|
}
|
|
82
121
|
accept(sample) {
|
|
83
122
|
if (this.closed)
|
|
84
123
|
throw new Error(`Client ${this.clientId} is closed`);
|
|
85
124
|
const now = Date.now();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
125
|
+
const elapsedInMs = now - this.updated;
|
|
126
|
+
const elapsedInSeconds = elapsedInMs / 1000;
|
|
127
|
+
let sumOfRtts = 0;
|
|
128
|
+
let numberOfRttMeasurements = 0;
|
|
129
|
+
++this.acceptedSamples;
|
|
130
|
+
this.availableIncomingBitrate = 0;
|
|
131
|
+
this.availableOutgoingBitrate = 0;
|
|
132
|
+
this.deltaDataChannelBytesReceived = 0;
|
|
133
|
+
this.deltaDataChannelBytesSent = 0;
|
|
134
|
+
this.deltaDataChannelMessagesReceived = 0;
|
|
135
|
+
this.deltaDataChannelMessagesSent = 0;
|
|
136
|
+
this.deltaInboundPacketsLost = 0;
|
|
137
|
+
this.deltaInboundPacketsReceived = 0;
|
|
138
|
+
this.deltaOutboundPacketsSent = 0;
|
|
139
|
+
this.deltaReceivedAudioBytes = 0;
|
|
140
|
+
this.deltaReceivedVideoBytes = 0;
|
|
141
|
+
this.deltaSentAudioBytes = 0;
|
|
142
|
+
this.deltaSentVideoBytes = 0;
|
|
143
|
+
this.deltaTransportReceivedBytes = 0;
|
|
144
|
+
this.deltaTransportSentBytes = 0;
|
|
145
|
+
this.deltaRttLt50Measurements = 0;
|
|
146
|
+
this.deltaRttLt150Measurements = 0;
|
|
147
|
+
this.deltaRttLt300Measurements = 0;
|
|
148
|
+
this.deltaRttGtOrEq300Measurements = 0;
|
|
149
|
+
this.deltaNumberOfIssues = 0;
|
|
150
|
+
this.numberOfDataChannels = 0;
|
|
151
|
+
this.numberOfInboundRtpStreams = 0;
|
|
152
|
+
this.numberOfInbundTracks = 0;
|
|
153
|
+
this.numberOfOutboundRtpStreams = 0;
|
|
154
|
+
this.numberOfOutboundTracks = 0;
|
|
155
|
+
this.usingTURN = false;
|
|
156
|
+
this.usingTCP = false;
|
|
157
|
+
this.currentMinRttInMs = undefined;
|
|
158
|
+
this.currentMaxRttInMs = undefined;
|
|
159
|
+
this._mergeInjections(sample);
|
|
160
|
+
const clientEventsPostBuffer = [];
|
|
161
|
+
for (const clientEvent of sample.clientEvents ?? []) {
|
|
162
|
+
this._processClientEvent(clientEvent, clientEventsPostBuffer);
|
|
163
|
+
this.call.observer.emit('client-event', this, clientEvent);
|
|
164
|
+
}
|
|
165
|
+
for (const metaData of sample.clientMetaItems ?? []) {
|
|
166
|
+
this.addMetadata(metaData);
|
|
167
|
+
}
|
|
168
|
+
for (const issue of sample.clientIssues ?? []) {
|
|
169
|
+
this.addIssue(issue);
|
|
170
|
+
++this.deltaNumberOfIssues;
|
|
171
|
+
}
|
|
172
|
+
for (const extensionStat of sample.extensionStats ?? []) {
|
|
173
|
+
this.addExtensionStats(extensionStat);
|
|
174
|
+
}
|
|
175
|
+
for (const pcSample of sample.peerConnections ?? []) {
|
|
176
|
+
const observedPeerConnection = this._updatePeerConnection(pcSample);
|
|
177
|
+
if (!observedPeerConnection)
|
|
178
|
+
continue;
|
|
179
|
+
this.deltaDataChannelBytesReceived += observedPeerConnection.deltaDataChannelBytesReceived;
|
|
180
|
+
this.deltaDataChannelBytesSent += observedPeerConnection.deltaDataChannelBytesSent;
|
|
181
|
+
this.deltaDataChannelMessagesReceived += observedPeerConnection.deltaDataChannelMessagesReceived;
|
|
182
|
+
this.deltaDataChannelMessagesSent += observedPeerConnection.deltaDataChannelMessagesSent;
|
|
183
|
+
this.deltaInboundPacketsLost += observedPeerConnection.deltaInboundPacketsLost;
|
|
184
|
+
this.deltaInboundPacketsReceived += observedPeerConnection.deltaInboundPacketsReceived;
|
|
185
|
+
this.deltaOutboundPacketsSent += observedPeerConnection.deltaOutboundPacketsSent;
|
|
186
|
+
this.deltaReceivedAudioBytes += observedPeerConnection.deltaReceivedAudioBytes;
|
|
187
|
+
this.deltaReceivedVideoBytes += observedPeerConnection.deltaReceivedVideoBytes;
|
|
188
|
+
this.deltaSentAudioBytes += observedPeerConnection.deltaSentAudioBytes;
|
|
189
|
+
this.deltaSentVideoBytes += observedPeerConnection.deltaSentVideoBytes;
|
|
190
|
+
this.deltaTransportReceivedBytes += observedPeerConnection.deltaTransportReceivedBytes;
|
|
191
|
+
this.deltaTransportSentBytes += observedPeerConnection.deltaTransportSentBytes;
|
|
192
|
+
this.availableIncomingBitrate += observedPeerConnection.availableIncomingBitrate;
|
|
193
|
+
this.availableOutgoingBitrate += observedPeerConnection.availableOutgoingBitrate;
|
|
194
|
+
this.numberOfDataChannels += observedPeerConnection.observedDataChannels.size;
|
|
195
|
+
this.numberOfInbundTracks += observedPeerConnection.observedInboundTracks.size;
|
|
196
|
+
this.numberOfOutboundRtpStreams += observedPeerConnection.observedOutboundRtps.size;
|
|
197
|
+
this.numberOfOutboundTracks += observedPeerConnection.observedOutboundTracks.size;
|
|
198
|
+
this.numberOfInboundRtpStreams += observedPeerConnection.observedInboundRtps.size;
|
|
199
|
+
if (observedPeerConnection.usingTURN) {
|
|
200
|
+
this.usingTURN = true;
|
|
201
|
+
}
|
|
202
|
+
if (observedPeerConnection.usingTCP) {
|
|
203
|
+
this.usingTCP = true;
|
|
204
|
+
}
|
|
205
|
+
if (observedPeerConnection.currentRttInMs) {
|
|
206
|
+
if (this.currentMinRttInMs === undefined || observedPeerConnection.currentRttInMs < this.currentMinRttInMs) {
|
|
207
|
+
this.currentMinRttInMs = observedPeerConnection.currentRttInMs;
|
|
208
|
+
}
|
|
209
|
+
if (this.currentMaxRttInMs === undefined || observedPeerConnection.currentRttInMs > this.currentMaxRttInMs) {
|
|
210
|
+
this.currentMaxRttInMs = observedPeerConnection.currentRttInMs;
|
|
211
|
+
}
|
|
212
|
+
if (observedPeerConnection.currentRttInMs < 50) {
|
|
213
|
+
this.deltaRttLt50Measurements += 1;
|
|
214
|
+
}
|
|
215
|
+
else if (observedPeerConnection.currentRttInMs < 150) {
|
|
216
|
+
this.deltaRttLt150Measurements += 1;
|
|
217
|
+
}
|
|
218
|
+
else if (observedPeerConnection.currentRttInMs < 300) {
|
|
219
|
+
this.deltaRttLt300Measurements += 1;
|
|
220
|
+
}
|
|
221
|
+
else if (300 <= observedPeerConnection.currentRttInMs) {
|
|
222
|
+
this.deltaRttGtOrEq300Measurements += 1;
|
|
223
|
+
}
|
|
224
|
+
sumOfRtts += observedPeerConnection.currentRttInMs;
|
|
225
|
+
++numberOfRttMeasurements;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
for (const clientEvent of clientEventsPostBuffer) {
|
|
229
|
+
this._processClientEvent(clientEvent);
|
|
230
|
+
}
|
|
91
231
|
// emit new attachments?
|
|
92
232
|
this.attachments = sample.attachments;
|
|
233
|
+
this.totalDataChannelBytesReceived += this.deltaDataChannelBytesReceived;
|
|
234
|
+
this.totalDataChannelBytesSent += this.deltaDataChannelBytesSent;
|
|
235
|
+
this.totalDataChannelMessagesReceived += this.deltaDataChannelMessagesReceived;
|
|
236
|
+
this.totalDataChannelMessagesSent += this.deltaDataChannelMessagesSent;
|
|
237
|
+
this.totalInboundPacketsLost += this.deltaInboundPacketsLost;
|
|
238
|
+
this.totalInboundPacketsReceived += this.deltaInboundPacketsReceived;
|
|
239
|
+
this.totalOutboundPacketsSent += this.deltaOutboundPacketsSent;
|
|
240
|
+
this.totalReceivedAudioBytes += this.deltaReceivedAudioBytes;
|
|
241
|
+
this.totalReceivedVideoBytes += this.deltaReceivedVideoBytes;
|
|
242
|
+
this.totalSentAudioBytes += this.deltaSentAudioBytes;
|
|
243
|
+
this.totalSentVideoBytes += this.deltaSentVideoBytes;
|
|
244
|
+
this.totalReceivedBytes += this.deltaTransportReceivedBytes;
|
|
245
|
+
this.totalSentBytes += this.deltaTransportSentBytes;
|
|
246
|
+
this.totalRttLt50Measurements += this.deltaRttLt50Measurements;
|
|
247
|
+
this.totalRttLt150Measurements += this.deltaRttLt150Measurements;
|
|
248
|
+
this.totalRttLt300Measurements += this.deltaRttLt300Measurements;
|
|
249
|
+
this.totalRttGtOrEq300Measurements += this.deltaRttGtOrEq300Measurements;
|
|
250
|
+
this.totalNumberOfIssues += this.deltaNumberOfIssues;
|
|
251
|
+
this.receivingAudioBitrate = (this.deltaReceivedAudioBytes * 8) / (elapsedInSeconds);
|
|
252
|
+
this.receivingVideoBitrate = (this.totalReceivedVideoBytes * 8) / (elapsedInSeconds);
|
|
253
|
+
this.sendingAudioBitrate = (this.deltaSentAudioBytes * 8) / (elapsedInSeconds);
|
|
254
|
+
this.sendingVideoBitrate = (this.deltaSentVideoBytes * 8) / (elapsedInSeconds);
|
|
255
|
+
this.currentAvgRttInMs = 0 < numberOfRttMeasurements ? sumOfRtts / numberOfRttMeasurements : undefined;
|
|
93
256
|
this.calculatedScore.value = sample.score;
|
|
94
257
|
this.detectors.update();
|
|
258
|
+
this.lastSampleTimestamp = sample.timestamp;
|
|
95
259
|
// emit update
|
|
96
260
|
this.emit('update', {
|
|
97
261
|
sample,
|
|
98
262
|
elapsedTimeInMs: now - this.updated,
|
|
99
263
|
});
|
|
100
264
|
this.updated = now;
|
|
265
|
+
// if result changed after update
|
|
266
|
+
if (this.calculatedScore.value) {
|
|
267
|
+
this.totalScoreSum += this.calculatedScore.value;
|
|
268
|
+
++this.numberOfScoreMeasurements;
|
|
269
|
+
}
|
|
101
270
|
}
|
|
102
|
-
_processClientEvent(event) {
|
|
271
|
+
_processClientEvent(event, postBuffer) {
|
|
272
|
+
// eslint-disable-next-line no-console
|
|
273
|
+
// console.warn('ClientEvent', event);
|
|
103
274
|
switch (event.type) {
|
|
104
|
-
case
|
|
105
|
-
// update call timestamp if it's the first time
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
case eventTypes_1.ClientEventType.CALL_ENDED: {
|
|
109
|
-
// update call timestamp if it's the first time
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case eventTypes_1.ClientEventType.CLIENT_JOINED: {
|
|
275
|
+
case ClientEventTypes_1.ClientEventTypes.CLIENT_JOINED: {
|
|
113
276
|
if (event.timestamp) {
|
|
114
277
|
if (!this.joinedAt) {
|
|
115
278
|
this.joinedAt = event.timestamp;
|
|
@@ -123,76 +286,350 @@ class ObservedClient extends events_1.EventEmitter {
|
|
|
123
286
|
logger.warn(`Client ${this.clientId} joinedAt timestamp was updated to ${event.timestamp}. the joined event will not be emitted.`);
|
|
124
287
|
}
|
|
125
288
|
}
|
|
289
|
+
logger.debug('Client %s joined at %o', this.clientId, event);
|
|
126
290
|
break;
|
|
127
291
|
}
|
|
128
|
-
case
|
|
292
|
+
case ClientEventTypes_1.ClientEventTypes.CLIENT_LEFT: {
|
|
129
293
|
if (event.timestamp) {
|
|
130
294
|
if (!this.leftAt) {
|
|
131
295
|
this.leftAt = event.timestamp;
|
|
132
296
|
this.emit('left');
|
|
133
297
|
}
|
|
298
|
+
else {
|
|
299
|
+
logger.warn(`Client ${this.clientId} leftAt timestamp was already set`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
logger.debug('Client %s left at %o', this.clientId, event);
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
case ClientEventTypes_1.ClientEventTypes.PEER_CONNECTION_OPENED: {
|
|
306
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
307
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string') {
|
|
308
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
309
|
+
if (observedPeerConnection) {
|
|
310
|
+
observedPeerConnection.openedAt = event.timestamp;
|
|
311
|
+
}
|
|
312
|
+
else if (postBuffer) {
|
|
313
|
+
postBuffer.push(event);
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
logger.warn('Received PEER_CONNECTION_OPENED event without a corresponding observedPeerConnection: %o', event);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
break;
|
|
320
|
+
}
|
|
321
|
+
case ClientEventTypes_1.ClientEventTypes.PEER_CONNECTION_CLOSED: {
|
|
322
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
323
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string') {
|
|
324
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
325
|
+
if (observedPeerConnection) {
|
|
326
|
+
observedPeerConnection.closedAt = event.timestamp;
|
|
327
|
+
}
|
|
328
|
+
else if (postBuffer) {
|
|
329
|
+
postBuffer.push(event);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
logger.warn('Received PEER_CONNECTION_CLOSED event without a corresponding observedPeerConnection: %o', event);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
case ClientEventTypes_1.ClientEventTypes.MEDIA_TRACK_ADDED: {
|
|
338
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
339
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.trackId && typeof payload.trackId === 'string') {
|
|
340
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
341
|
+
const observedTrack = observedPeerConnection?.observedInboundTracks.get(payload.trackId) ?? observedPeerConnection?.observedOutboundTracks.get(payload.trackId);
|
|
342
|
+
if (observedTrack) {
|
|
343
|
+
observedTrack.addedAt = event.timestamp;
|
|
344
|
+
}
|
|
345
|
+
else if (postBuffer) {
|
|
346
|
+
postBuffer.push(event);
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
logger.warn('Received MEDIA_TRACK_ADDED event without a corresponding observedPeerConnection or observedTrack: %o', event);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
break;
|
|
353
|
+
}
|
|
354
|
+
case ClientEventTypes_1.ClientEventTypes.MEDIA_TRACK_REMOVED: {
|
|
355
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
356
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.trackId && typeof payload.trackId === 'string') {
|
|
357
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
358
|
+
const observedTrack = observedPeerConnection?.observedInboundTracks.get(payload.trackId) ?? observedPeerConnection?.observedOutboundTracks.get(payload.trackId);
|
|
359
|
+
if (observedTrack) {
|
|
360
|
+
observedTrack.removedAt = event.timestamp;
|
|
361
|
+
}
|
|
362
|
+
else if (postBuffer) {
|
|
363
|
+
postBuffer.push(event);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
logger.warn('Received MEDIA_TRACK_REMOVED event without a corresponding observedPeerConnection or observedTrack: %o', event);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
case ClientEventTypes_1.ClientEventTypes.DATA_CHANNEL_OPEN: {
|
|
372
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
373
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.dataChannelId && typeof payload.dataChannelId === 'string') {
|
|
374
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
375
|
+
const observedDataChannel = observedPeerConnection?.observedDataChannels.get(payload.dataChannelId);
|
|
376
|
+
if (observedDataChannel) {
|
|
377
|
+
observedDataChannel.addedAt = event.timestamp;
|
|
378
|
+
}
|
|
379
|
+
else if (postBuffer) {
|
|
380
|
+
postBuffer.push(event);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
logger.warn('Received DATA_CHANNEL_OPENED event without a corresponding observedPeerConnection or observedDataChannel: %o', event);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
case ClientEventTypes_1.ClientEventTypes.DATA_CHANNEL_CLOSED: {
|
|
389
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
390
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.dataChannelId && typeof payload.dataChannelId === 'string') {
|
|
391
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
392
|
+
const observedDataChannel = observedPeerConnection?.observedDataChannels.get(payload.dataChannelId);
|
|
393
|
+
if (observedDataChannel) {
|
|
394
|
+
observedDataChannel.removedAt = event.timestamp;
|
|
395
|
+
}
|
|
396
|
+
else if (postBuffer) {
|
|
397
|
+
postBuffer.push(event);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
logger.warn('Received DATA_CHANNEL_CLOSE event without a corresponding observedPeerConnection or observedDataChannel: %o', event);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
case ClientEventTypes_1.ClientEventTypes.MEDIA_TRACK_MUTED: {
|
|
406
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
407
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.trackId && typeof payload.trackId === 'string') {
|
|
408
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
409
|
+
const observedInboundTrack = observedPeerConnection?.observedInboundTracks.get(payload.trackId);
|
|
410
|
+
const observedOutboundTrack = observedPeerConnection?.observedOutboundTracks.get(payload.trackId);
|
|
411
|
+
if (observedPeerConnection) {
|
|
412
|
+
if (observedInboundTrack) {
|
|
413
|
+
observedInboundTrack.muted = true;
|
|
414
|
+
observedPeerConnection?.emit('muted-inbound-track', observedInboundTrack);
|
|
415
|
+
}
|
|
416
|
+
else if (observedOutboundTrack) {
|
|
417
|
+
observedOutboundTrack.muted = true;
|
|
418
|
+
observedPeerConnection?.emit('muted-outbound-track', observedOutboundTrack);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
else if (postBuffer) {
|
|
422
|
+
postBuffer.push(event);
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
logger.warn('Received MEDIA_TRACK_MUTED event without a corresponding observedPeerConnection or observedTrack: %o', event);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
case ClientEventTypes_1.ClientEventTypes.MEDIA_TRACK_UNMUTED: {
|
|
431
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
432
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.trackId && typeof payload.trackId === 'string') {
|
|
433
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
434
|
+
const observedInboundTrack = observedPeerConnection?.observedInboundTracks.get(payload.trackId);
|
|
435
|
+
const observedOutboundTrack = observedPeerConnection?.observedOutboundTracks.get(payload.trackId);
|
|
436
|
+
if (observedPeerConnection) {
|
|
437
|
+
if (observedInboundTrack) {
|
|
438
|
+
observedInboundTrack.muted = false;
|
|
439
|
+
observedPeerConnection?.emit('unmuted-inbound-track', observedInboundTrack);
|
|
440
|
+
}
|
|
441
|
+
else if (observedOutboundTrack) {
|
|
442
|
+
observedOutboundTrack.muted = false;
|
|
443
|
+
observedPeerConnection?.emit('unmuted-outbound-track', observedOutboundTrack);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
else if (postBuffer) {
|
|
447
|
+
postBuffer.push(event);
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
logger.warn('Received MEDIA_TRACK_UNMUTED event without a corresponding observedPeerConnection or observedTrack: %o', event);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
case ClientEventTypes_1.ClientEventTypes.ICE_CONNECTION_STATE_CHANGED: {
|
|
456
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
457
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.iceConnectionState && typeof payload.iceConnectionState === 'string') {
|
|
458
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
459
|
+
if (observedPeerConnection) {
|
|
460
|
+
observedPeerConnection.iceConnectionState = payload.iceConnectionState;
|
|
461
|
+
observedPeerConnection.emit('iceconnectionstatechange', {
|
|
462
|
+
state: payload.iceConnectionState,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
else if (postBuffer) {
|
|
466
|
+
postBuffer.push(event);
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
logger.warn('Received ICE_CONNECTION_STATE_CHANGED event without a corresponding observedPeerConnection: %o', event);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
case ClientEventTypes_1.ClientEventTypes.ICE_GATHERING_STATE_CHANGED: {
|
|
475
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
476
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.iceGatheringState && typeof payload.iceGatheringState === 'string') {
|
|
477
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
478
|
+
if (observedPeerConnection) {
|
|
479
|
+
observedPeerConnection.iceGatheringState = payload.iceGatheringState;
|
|
480
|
+
observedPeerConnection.emit('icegatheringstatechange', {
|
|
481
|
+
state: payload.iceGatheringState,
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
else if (postBuffer) {
|
|
485
|
+
postBuffer.push(event);
|
|
486
|
+
}
|
|
487
|
+
else {
|
|
488
|
+
logger.warn('Received ICE_GATHERING_STATE_CHANGED event without a corresponding observedPeerConnection: %o', event);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
case ClientEventTypes_1.ClientEventTypes.PEER_CONNECTION_STATE_CHANGED: {
|
|
494
|
+
const payload = (0, utils_1.parseJsonAs)(event.payload);
|
|
495
|
+
if (payload?.peerConnectionId && typeof payload.peerConnectionId === 'string' && payload?.peerConnectionState && typeof payload.peerConnectionState === 'string') {
|
|
496
|
+
const observedPeerConnection = this.observedPeerConnections.get(payload.peerConnectionId);
|
|
497
|
+
if (observedPeerConnection) {
|
|
498
|
+
observedPeerConnection.connectionState = payload.peerConnectionState;
|
|
499
|
+
observedPeerConnection.emit('connectionstatechange', {
|
|
500
|
+
state: payload.peerConnectionState,
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
else if (postBuffer) {
|
|
504
|
+
postBuffer.push(event);
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
logger.warn('Received PEER_CONNECTION_STATE_CHANGED event without a corresponding observedPeerConnection: %o', event);
|
|
508
|
+
}
|
|
134
509
|
}
|
|
135
510
|
break;
|
|
136
511
|
}
|
|
137
512
|
}
|
|
138
|
-
this.
|
|
139
|
-
call: this.call,
|
|
140
|
-
client: this,
|
|
141
|
-
data: event,
|
|
142
|
-
});
|
|
513
|
+
this.emit('clientEvent', event);
|
|
143
514
|
}
|
|
144
|
-
|
|
515
|
+
injectMetaData(metaData) {
|
|
516
|
+
if (this.closed)
|
|
517
|
+
return;
|
|
518
|
+
if (!this._injections.clientMetaItems)
|
|
519
|
+
this._injections.clientMetaItems = [];
|
|
520
|
+
this._injections.clientMetaItems.push(metaData);
|
|
521
|
+
}
|
|
522
|
+
injectEvent(event) {
|
|
523
|
+
if (this.closed)
|
|
524
|
+
return;
|
|
525
|
+
if (!this._injections.clientEvents)
|
|
526
|
+
this._injections.clientEvents = [];
|
|
527
|
+
this._injections.clientEvents.push(event);
|
|
528
|
+
}
|
|
529
|
+
injectIssue(issue) {
|
|
530
|
+
if (this.closed)
|
|
531
|
+
return;
|
|
532
|
+
if (!this._injections.clientIssues)
|
|
533
|
+
this._injections.clientIssues = [];
|
|
534
|
+
this._injections.clientIssues.push(issue);
|
|
535
|
+
}
|
|
536
|
+
injectExtensionStat(stat) {
|
|
537
|
+
if (this.closed)
|
|
538
|
+
return;
|
|
539
|
+
if (!this._injections.extensionStats)
|
|
540
|
+
this._injections.extensionStats = [];
|
|
541
|
+
this._injections.extensionStats.push(stat);
|
|
542
|
+
}
|
|
543
|
+
injectAttachment(key, value) {
|
|
544
|
+
if (this.closed)
|
|
545
|
+
return;
|
|
546
|
+
if (!this._injections.attachments)
|
|
547
|
+
this._injections.attachments = {};
|
|
548
|
+
this._injections.attachments[key] = value;
|
|
549
|
+
}
|
|
550
|
+
addMetadata(metadata) {
|
|
551
|
+
if (this.closed)
|
|
552
|
+
return;
|
|
145
553
|
switch (metadata.type) {
|
|
146
|
-
case
|
|
554
|
+
case ClientMetaTypes_1.ClientMetaTypes.BROWSER: {
|
|
147
555
|
this.browser = (0, utils_1.parseJsonAs)(metadata.payload);
|
|
148
556
|
break;
|
|
149
557
|
}
|
|
150
|
-
case
|
|
558
|
+
case ClientMetaTypes_1.ClientMetaTypes.ENGINE: {
|
|
151
559
|
this.engine = (0, utils_1.parseJsonAs)(metadata.payload);
|
|
152
560
|
break;
|
|
153
561
|
}
|
|
154
|
-
case
|
|
562
|
+
case ClientMetaTypes_1.ClientMetaTypes.PLATFORM: {
|
|
155
563
|
this.platform = (0, utils_1.parseJsonAs)(metadata.payload);
|
|
156
564
|
break;
|
|
157
565
|
}
|
|
158
|
-
case
|
|
566
|
+
case ClientMetaTypes_1.ClientMetaTypes.OPERATION_SYSTEM: {
|
|
159
567
|
this.operationSystem = (0, utils_1.parseJsonAs)(metadata.payload);
|
|
160
568
|
break;
|
|
161
569
|
}
|
|
162
570
|
}
|
|
163
|
-
this.call.observer.
|
|
164
|
-
call: this.call,
|
|
165
|
-
client: this,
|
|
166
|
-
data: metadata,
|
|
167
|
-
});
|
|
571
|
+
this.call.observer.emit('client-metadata', this, metadata);
|
|
168
572
|
}
|
|
169
|
-
|
|
170
|
-
this.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
});
|
|
573
|
+
addIssue(issue) {
|
|
574
|
+
if (this.closed)
|
|
575
|
+
return;
|
|
576
|
+
this.emit('issue', issue);
|
|
577
|
+
this.call.observer.emit('client-issue', this, issue);
|
|
175
578
|
}
|
|
176
|
-
|
|
177
|
-
this.call.observer.
|
|
178
|
-
|
|
179
|
-
client: this,
|
|
180
|
-
data: stats,
|
|
181
|
-
});
|
|
579
|
+
addExtensionStats(stats) {
|
|
580
|
+
this.call.observer.emit('client-extension-stats', this, stats);
|
|
581
|
+
this.emit('extensionStats', stats);
|
|
182
582
|
}
|
|
183
583
|
_updatePeerConnection(sample) {
|
|
184
584
|
let observedPeerConnection = this.observedPeerConnections.get(sample.peerConnectionId);
|
|
185
585
|
if (!observedPeerConnection) {
|
|
186
586
|
if (!sample.peerConnectionId) {
|
|
187
|
-
return logger.warn(`ObservedClient received an invalid PeerConnectionSample (missing peerConnectionId field). ClientId: ${this.clientId}, CallId: ${this.call.callId}`, sample);
|
|
587
|
+
return (logger.warn(`ObservedClient received an invalid PeerConnectionSample (missing peerConnectionId field). ClientId: ${this.clientId}, CallId: ${this.call.callId}`, sample), void 0);
|
|
188
588
|
}
|
|
189
589
|
observedPeerConnection = new ObservedPeerConnection_1.ObservedPeerConnection(sample.peerConnectionId, this);
|
|
190
590
|
observedPeerConnection.once('close', () => {
|
|
191
591
|
this.observedPeerConnections.delete(sample.peerConnectionId);
|
|
192
592
|
});
|
|
193
593
|
this.observedPeerConnections.set(sample.peerConnectionId, observedPeerConnection);
|
|
594
|
+
this.emit('newpeerconnection', observedPeerConnection);
|
|
194
595
|
}
|
|
195
596
|
observedPeerConnection.accept(sample);
|
|
597
|
+
return observedPeerConnection;
|
|
598
|
+
}
|
|
599
|
+
_mergeInjections(sample) {
|
|
600
|
+
if (this.closed)
|
|
601
|
+
return sample;
|
|
602
|
+
if (this._injections.clientEvents) {
|
|
603
|
+
if (!sample.clientEvents)
|
|
604
|
+
sample.clientEvents = [];
|
|
605
|
+
sample.clientEvents.push(...this._injections.clientEvents);
|
|
606
|
+
this._injections.clientEvents = undefined;
|
|
607
|
+
}
|
|
608
|
+
if (this._injections.clientIssues) {
|
|
609
|
+
if (!sample.clientIssues)
|
|
610
|
+
sample.clientIssues = [];
|
|
611
|
+
sample.clientIssues.push(...this._injections.clientIssues);
|
|
612
|
+
this._injections.clientIssues = undefined;
|
|
613
|
+
}
|
|
614
|
+
if (this._injections.extensionStats) {
|
|
615
|
+
if (!sample.extensionStats)
|
|
616
|
+
sample.extensionStats = [];
|
|
617
|
+
sample.extensionStats.push(...this._injections.extensionStats);
|
|
618
|
+
this._injections.extensionStats = undefined;
|
|
619
|
+
}
|
|
620
|
+
if (this._injections.attachments) {
|
|
621
|
+
if (!sample.attachments)
|
|
622
|
+
sample.attachments = {};
|
|
623
|
+
Object.assign(sample.attachments, this._injections.attachments);
|
|
624
|
+
this._injections.attachments = undefined;
|
|
625
|
+
}
|
|
626
|
+
if (this._injections.clientMetaItems) {
|
|
627
|
+
if (!sample.clientMetaItems)
|
|
628
|
+
sample.clientMetaItems = [];
|
|
629
|
+
sample.clientMetaItems.push(...this._injections.clientMetaItems);
|
|
630
|
+
this._injections.clientMetaItems = undefined;
|
|
631
|
+
}
|
|
632
|
+
return sample;
|
|
196
633
|
}
|
|
197
634
|
}
|
|
198
635
|
exports.ObservedClient = ObservedClient;
|