Skip to content

Commit

Permalink
Improve the way we look for Erizo Client Connections internally (#1544)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcague authored Feb 24, 2020
1 parent a1bc273 commit b121802
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
12 changes: 12 additions & 0 deletions erizo_controller/erizoClient/src/ErizoConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ class ErizoConnectionManager {
this.ErizoConnectionsMap = new Map(); // key: erizoId, value: {connectionId: connection}
}

getErizoConnection(erizoConnectionId) {
let connection;
this.ErizoConnectionsMap.forEach((entry) => {
Object.keys(entry).forEach((entryKey) => {
if (entry[entryKey].connectionId === erizoConnectionId) {
connection = entry[entryKey];
}
});
});
return connection;
}

getOrBuildErizoConnection(specInput, erizoId = undefined, singlePC = false) {
Logger.debug(`message: getOrBuildErizoConnection, erizoId: ${erizoId}`);
let connection = {};
Expand Down
21 changes: 4 additions & 17 deletions erizo_controller/erizoClient/src/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,27 +386,14 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => {
};

const socketOnConnectionMessageFromErizo = (arg) => {
let done = false;
if (arg.evt.type === 'quality_level') {
socketOnConnectionQualityLevel(arg);
return;
}
localStreams.forEach((stream) => {
if (!done && !stream.failed && stream.pc && stream.pc.connectionId === arg.connectionId) {
stream.pc.processSignalingMessage(arg.evt);
done = true;
}
});
if (done) {
return;
}
remoteStreams.forEach((stream) => {
if (!done && !stream.failed && stream.pc && stream.pc.connectionId === arg.connectionId) {
stream.pc.processSignalingMessage(arg.evt);
done = true;
}
});
if (!done) {
const connection = that.erizoConnectionManager.getErizoConnection(arg.connectionId);
if (connection) {
connection.processSignalingMessage(arg.evt);
} else {
Logger.warning('Received signaling message to unknown connectionId', arg.connectionId);
}
};
Expand Down

0 comments on commit b121802

Please sign in to comment.