Skip to content

Commit

Permalink
Fix the way ICE propagates connection state events (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
kekkokk authored and jcague committed May 30, 2018
1 parent 7c5945c commit a748d25
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 2 additions & 1 deletion erizo_controller/erizoClient/src/ErizoConnectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class ErizoConnection extends EventEmitterConst {
this.emit(ConnectionEvent({ type: 'remove-stream', stream: evt.stream }));
};

this.stack.peerConnection.oniceconnectionstatechange = (state) => {
this.stack.peerConnection.oniceconnectionstatechange = () => {
const state = this.stack.peerConnection.iceConnectionState;
this.emit(ConnectionEvent({ type: 'ice-state-change', state }));
};
}
Expand Down
12 changes: 8 additions & 4 deletions erizo_controller/erizoClient/src/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => {
getP2PConnectionOptions(stream, peerSocket)));
stream.on('added', dispatchStreamSubscribed.bind(null, stream));
stream.on('icestatechanged', (evt) => {
if (evt.state === 'failed') {
Logger.info(`${stream.getID()} - iceConnectionState: ${evt.msg.state}`);
if (evt.msg.state === 'failed') {
onStreamFailed(stream);
}
});
Expand All @@ -139,7 +140,8 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => {
stream.addPC(connection, peerSocket);

stream.on('icestatechanged', (evt) => {
if (evt.state === 'failed') {
Logger.info(`${stream.getID()} - iceConnectionState: ${evt.msg.state}`);
if (evt.msg.state === 'failed') {
stream.pc.get(peerSocket).close();
stream.pc.remove(peerSocket);
}
Expand Down Expand Up @@ -193,7 +195,8 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => {
getErizoConnectionOptions(stream, options, true), erizoId, spec.singlePC));
stream.on('added', dispatchStreamSubscribed.bind(null, stream));
stream.on('icestatechanged', (evt) => {
if (evt.state === 'failed') {
Logger.info(`${stream.getID()} - iceConnectionState: ${evt.msg.state}`);
if (evt.msg.state === 'failed') {
onStreamFailed(stream);
}
});
Expand All @@ -206,7 +209,8 @@ const Room = (altIo, altConnectionHelpers, altConnectionManager, specInput) => {
getErizoConnectionOptions(stream, options), erizoId, spec.singlePC));

stream.on('icestatechanged', (evt) => {
if (evt.state === 'failed') {
Logger.info(`${stream.getID()} - iceConnectionState: ${evt.msg.state}`);
if (evt.msg.state === 'failed') {
onStreamFailed(stream);
}
});
Expand Down
4 changes: 2 additions & 2 deletions erizo_controller/erizoClient/src/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ const Stream = (altConnectionHelpers, specInput) => {
}
};

const onICEConnectionStateChange = (state) => {
that.emit(StreamEvent({ type: 'icestatechanged', msg: state }));
const onICEConnectionStateChange = (msg) => {
that.emit(StreamEvent({ type: 'icestatechanged', msg }));
};

if (that.videoSize !== undefined &&
Expand Down

0 comments on commit a748d25

Please sign in to comment.