|
@@ -204,7 +204,14 @@ Statistics.prototype.removeByteSentStatsListener = function(listener) {
|
204
|
204
|
|
205
|
205
|
Statistics.prototype.dispose = function() {
|
206
|
206
|
try {
|
207
|
|
- if (this.eventEmitter) {
|
|
207
|
+ // NOTE Before reading this please see the comment in stopCallStats...
|
|
208
|
+ //
|
|
209
|
+ // Here we prevent from emitting the event twice in case it will be
|
|
210
|
+ // triggered from stopCallStats.
|
|
211
|
+ // If the event is triggered from here it means that the logs will not
|
|
212
|
+ // be submitted anyway (because there is no CallStats instance), but
|
|
213
|
+ // we're doing that for the sake of some kind of consistency.
|
|
214
|
+ if (!this.callsStatsInstances.size) {
|
208
|
215
|
this.eventEmitter.emit(StatisticsEvents.BEFORE_DISPOSED);
|
209
|
216
|
}
|
210
|
217
|
for (const callStats of this.callsStatsInstances.values()) {
|
|
@@ -326,6 +333,18 @@ Statistics.prototype.stopCallStats = function(tpc) {
|
326
|
333
|
const callStatsInstance = this.callsStatsInstances.get(tpc.id);
|
327
|
334
|
|
328
|
335
|
if (callStatsInstance) {
|
|
336
|
+ // FIXME the original purpose of adding BEFORE_DISPOSED event was to be
|
|
337
|
+ // able to submit the last log batch from jitsi-meet to CallStats. After
|
|
338
|
+ // recent changes we dispose the CallStats earlier
|
|
339
|
+ // (before Statistics.dispose), so we need to emit this event here to
|
|
340
|
+ // give this last chance for final log batch submission.
|
|
341
|
+ //
|
|
342
|
+ // Eventually there should be a separate module called "log storage"
|
|
343
|
+ // which should emit proper events when it's underlying
|
|
344
|
+ // CallStats instance is going away.
|
|
345
|
+ if (this.callsStatsInstances.size === 1) {
|
|
346
|
+ this.eventEmitter.emit(StatisticsEvents.BEFORE_DISPOSED);
|
|
347
|
+ }
|
329
|
348
|
this.callsStatsInstances.delete(tpc.id);
|
330
|
349
|
|
331
|
350
|
// The fabric needs to be terminated when being stopped
|