瀏覽代碼

Load test: emulate Jitsi-Meet's lastN and selectParticipant behavior. (#8926)

j8
Jonathan Lennox 4 年之前
父節點
當前提交
357bbd1158
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 35 行新增5 行删除
  1. 35
    5
      resources/load-test/load-test-participant.js

+ 35
- 5
resources/load-test/load-test-participant.js 查看文件

@@ -3,6 +3,7 @@ import 'jquery';
3 3
 import { setConfigFromURLParams } from '../../react/features/base/config/functions';
4 4
 import { parseURLParams } from '../../react/features/base/util/parseURLParams';
5 5
 import { parseURIString } from '../../react/features/base/util/uri';
6
+import { validateLastNLimits, limitLastN } from '../../react/features/base/lastn/functions';
6 7
 
7 8
 setConfigFromURLParams(config, {}, {}, window.location);
8 9
 
@@ -107,12 +108,35 @@ function updateMaxFrameHeight() {
107 108
     }
108 109
 }
109 110
 
111
+/**
112
+ * Simple emulation of jitsi-meet's lastN behavior
113
+ */
114
+function updateLastN() {
115
+    let lastN = typeof config.channelLastN === 'undefined' ? -1 : config.channelLastN;
116
+
117
+    const limitedLastN = limitLastN(numParticipants, validateLastNLimits(config.lastNLimits));
118
+
119
+    if (limitedLastN !== undefined) {
120
+        lastN = lastN === -1 ? limitedLastN : Math.min(limitedLastN, lastN);
121
+    }
122
+
123
+    if (lastN === room.getLastN()) {
124
+        return;
125
+    }
126
+
127
+    room.setLastN(lastN);
128
+}
129
+
110 130
 /**
111 131
  *
112 132
  */
113 133
 function setNumberOfParticipants() {
114 134
     $('#participants').text(numParticipants);
135
+    /* jitsi-meet's current Tile View behavior. */
136
+    const ids = room.getParticipants().map(participant => participant.id);
137
+    room.selectParticipants(ids);
115 138
     updateMaxFrameHeight();
139
+    updateLastN();
116 140
 }
117 141
 
118 142
 /**
@@ -194,6 +218,16 @@ function onStartMuted() {
194 218
     }, 2000);
195 219
 }
196 220
 
221
+/**
222
+ *
223
+ * @param id
224
+ */
225
+function onUserJoined(id) {
226
+    numParticipants++;
227
+    setNumberOfParticipants();
228
+    remoteTracks[id] = [];
229
+}
230
+
197 231
 /**
198 232
  *
199 233
  * @param id
@@ -224,11 +258,7 @@ function onConnectionSuccess() {
224 258
     room.on(JitsiMeetJS.events.conference.STARTED_MUTED, onStartMuted);
225 259
     room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
226 260
     room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
227
-    room.on(JitsiMeetJS.events.conference.USER_JOINED, id => {
228
-        numParticipants++;
229
-        setNumberOfParticipants();
230
-        remoteTracks[id] = [];
231
-    });
261
+    room.on(JitsiMeetJS.events.conference.USER_JOINED, onUserJoined);
232 262
     room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
233 263
 
234 264
     const devices = [];

Loading…
取消
儲存