浏览代码

feat: add BEFORE_STATISTICS_DISPOSED event

master
paweldomas 8 年前
父节点
当前提交
935667f2fc
共有 5 个文件被更改,包括 33 次插入0 次删除
  1. 5
    0
      JitsiConferenceEventManager.js
  2. 8
    0
      JitsiConferenceEvents.js
  3. 1
    0
      doc/API.md
  4. 12
    0
      modules/statistics/statistics.js
  5. 7
    0
      service/statistics/Events.js

+ 5
- 0
JitsiConferenceEventManager.js 查看文件

@@ -548,6 +548,11 @@ JitsiConferenceEventManager.prototype.setupStatisticsListeners = function () {
548 548
 
549 549
         conference.rtc.setAudioLevel(resource, level);
550 550
     });
551
+    // Forward the "before stats disposed" event
552
+    conference.statistics.addBeforeDisposedListener(function () {
553
+        conference.eventEmitter.emit(
554
+            JitsiConferenceEvents.BEFORE_STATISTICS_DISPOSED);
555
+    });
551 556
     conference.statistics.addConnectionStatsListener(function (stats) {
552 557
         var ssrc2resolution = stats.resolution;
553 558
 

+ 8
- 0
JitsiConferenceEvents.js 查看文件

@@ -14,6 +14,14 @@ export const AVAILABLE_DEVICES_CHANGED = "conference.availableDevicesChanged";
14 14
  * A participant avatar has changed.
15 15
  */
16 16
 export const AVATAR_CHANGED = "conference.avatarChanged";
17
+
18
+/**
19
+ * Fired just before the statistics module is disposed and it's the last chance
20
+ * to submit some logs to the statistics service (ex. CallStats if enabled),
21
+ * before it's disconnected.
22
+ */
23
+export const BEFORE_STATISTICS_DISPOSED = "conference.beforeStatisticsDisposed";
24
+
17 25
 /**
18 26
  * Indicates that an error occured.
19 27
  */

+ 1
- 0
doc/API.md 查看文件

@@ -121,6 +121,7 @@ JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.ERROR);
121 121
         - STARTED_MUTED - notifies that the local user has started muted
122 122
         - AVAILABLE_DEVICES_CHANGED - notifies that available participant devices changed (camera or microphone was added or removed) (parameters - id(string), devices(JS object with 2 properties - audio(boolean), video(boolean)))
123 123
         - CONNECTION_STATS - New local connection statistics are received. (parameters - stats(object))
124
+        - BEFORE_STATISTICS_DISPOSED - fired just before the statistics module is disposed and it's the last chance to submit some logs to the statistics service, before it gets disconnected
124 125
         - AUTH_STATUS_CHANGED - notifies that authentication is enabled or disabled, or local user authenticated (logged in). (parameters - isAuthEnabled(boolean), authIdentity(string))
125 126
         - ENDPOINT_MESSAGE_RECEIVED - notifies that a new message
126 127
         from another participant is received on a data channel.

+ 12
- 0
modules/statistics/statistics.js 查看文件

@@ -144,6 +144,15 @@ Statistics.prototype.removeAudioLevelListener = function(listener) {
144 144
     this.eventEmitter.removeListener(StatisticsEvents.AUDIO_LEVEL, listener);
145 145
 };
146 146
 
147
+Statistics.prototype.addBeforeDisposedListener = function (listener) {
148
+    this.eventEmitter.on(StatisticsEvents.BEFORE_DISPOSED, listener);
149
+};
150
+
151
+Statistics.prototype.removeBeforeDisposedListener = function (listener) {
152
+    this.eventEmitter.removeListener(
153
+        StatisticsEvents.BEFORE_DISPOSED, listener);
154
+};
155
+
147 156
 Statistics.prototype.addConnectionStatsListener = function (listener) {
148 157
     this.eventEmitter.on(StatisticsEvents.CONNECTION_STATS, listener);
149 158
 };
@@ -162,6 +171,9 @@ Statistics.prototype.removeByteSentStatsListener = function (listener) {
162 171
 };
163 172
 
164 173
 Statistics.prototype.dispose = function () {
174
+    if (this.eventEmitter) {
175
+        this.eventEmitter.emit(StatisticsEvents.BEFORE_DISPOSED);
176
+    }
165 177
     this.stopCallStats();
166 178
     this.stopRemoteStats();
167 179
     if(this.eventEmitter)

+ 7
- 0
service/statistics/Events.js 查看文件

@@ -10,6 +10,13 @@
10 10
  */
11 11
 export const AUDIO_LEVEL = "statistics.audioLevel";
12 12
 
13
+/**
14
+ * An event fired just before the statistics module gets disposes and it's
15
+ * the last chance to submit some logs that will end up in stats services like
16
+ * CallStats (if enabled).
17
+ */
18
+export const BEFORE_DISPOSED = "statistics.before_disposed";
19
+
13 20
 /**
14 21
  * An event carrying all statistics by ssrc.
15 22
  */

正在加载...
取消
保存