Skip to content

Commit b121802

Browse files
authored
Improve the way we look for Erizo Client Connections internally (#1544)
1 parent a1bc273 commit b121802

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

erizo_controller/erizoClient/src/ErizoConnectionManager.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ class ErizoConnectionManager {
168168
this.ErizoConnectionsMap = new Map(); // key: erizoId, value: {connectionId: connection}
169169
}
170170

171+
getErizoConnection(erizoConnectionId) {
172+
let connection;
173+
this.ErizoConnectionsMap.forEach((entry) => {
174+
Object.keys(entry).forEach((entryKey) => {
175+
if (entry[entryKey].connectionId === erizoConnectionId) {
176+
connection = entry[entryKey];
177+
}
178+
});
179+
});
180+
return connection;
181+
}
182+
171183
getOrBuildErizoConnection(specInput, erizoId = undefined, singlePC = false) {
172184
Logger.debug(`message: getOrBuildErizoConnection, erizoId: ${erizoId}`);
173185
let connection = {};

erizo_controller/erizoClient/src/Room.js

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -386,27 +386,14 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => {
386386
};
387387

388388
const socketOnConnectionMessageFromErizo = (arg) => {
389-
let done = false;
390389
if (arg.evt.type === 'quality_level') {
391390
socketOnConnectionQualityLevel(arg);
392391
return;
393392
}
394-
localStreams.forEach((stream) => {
395-
if (!done && !stream.failed && stream.pc && stream.pc.connectionId === arg.connectionId) {
396-
stream.pc.processSignalingMessage(arg.evt);
397-
done = true;
398-
}
399-
});
400-
if (done) {
401-
return;
402-
}
403-
remoteStreams.forEach((stream) => {
404-
if (!done && !stream.failed && stream.pc && stream.pc.connectionId === arg.connectionId) {
405-
stream.pc.processSignalingMessage(arg.evt);
406-
done = true;
407-
}
408-
});
409-
if (!done) {
393+
const connection = that.erizoConnectionManager.getErizoConnection(arg.connectionId);
394+
if (connection) {
395+
connection.processSignalingMessage(arg.evt);
396+
} else {
410397
Logger.warning('Received signaling message to unknown connectionId', arg.connectionId);
411398
}
412399
};

0 commit comments

Comments
 (0)