瀏覽代碼

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

j8
Jonathan Lennox 4 年之前
父節點
當前提交
357bbd1158
No account linked to committer's email address
共有 1 個文件被更改,包括 35 次插入5 次删除
  1. 35
    5
      resources/load-test/load-test-participant.js

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

3
 import { setConfigFromURLParams } from '../../react/features/base/config/functions';
3
 import { setConfigFromURLParams } from '../../react/features/base/config/functions';
4
 import { parseURLParams } from '../../react/features/base/util/parseURLParams';
4
 import { parseURLParams } from '../../react/features/base/util/parseURLParams';
5
 import { parseURIString } from '../../react/features/base/util/uri';
5
 import { parseURIString } from '../../react/features/base/util/uri';
6
+import { validateLastNLimits, limitLastN } from '../../react/features/base/lastn/functions';
6
 
7
 
7
 setConfigFromURLParams(config, {}, {}, window.location);
8
 setConfigFromURLParams(config, {}, {}, window.location);
8
 
9
 
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
 function setNumberOfParticipants() {
133
 function setNumberOfParticipants() {
114
     $('#participants').text(numParticipants);
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
     updateMaxFrameHeight();
138
     updateMaxFrameHeight();
139
+    updateLastN();
116
 }
140
 }
117
 
141
 
118
 /**
142
 /**
194
     }, 2000);
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
  * @param id
233
  * @param id
224
     room.on(JitsiMeetJS.events.conference.STARTED_MUTED, onStartMuted);
258
     room.on(JitsiMeetJS.events.conference.STARTED_MUTED, onStartMuted);
225
     room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
259
     room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
226
     room.on(JitsiMeetJS.events.conference.CONFERENCE_JOINED, onConferenceJoined);
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
     room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
262
     room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);
233
 
263
 
234
     const devices = [];
264
     const devices = [];

Loading…
取消
儲存