-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added FSM to protect peerConnection use in basestack #1387
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this approach! have just a couple of minor comments
const PeerConnectionFsm = StateMachine.factory({ | ||
init: 'initial', | ||
transitions: [ | ||
{ name: 'create-offer', from: activeStates, to: 'stable' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I really like this pattern, which will help us tracking issues in the future.
}, 0); | ||
return Promise.resolve(); | ||
}, | ||
protectedRemoveStream: (stream) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep a blank line between functions in the protectedCalls and queuedCalls, to improve readability a bit
firstLocalDescriptionQueue.stopEnqueuing(); | ||
firstLocalDescriptionQueue.dequeueAll(); | ||
setTimeout(() => { | ||
negotiationQueue.stopEnqueuing(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why in general we protect calls to next items in negotiationQueue
and not to firstLocalDescriptionQueue
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because... They should also be protected, I'll fix it 👍
}, | ||
}); | ||
|
||
export default PeerConnectionFsm; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
getHistory: function getHistory() { | ||
return this.history; | ||
}, | ||
onBeforeClose: function onBeforeClose(lifecycle) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd leave a blank line between functions here too.
Also, is it possible to have lambdas here?
methods: {
getHistory: () => {
},
onBeforeClose: () => {
},
...
};
Possibly not due to the use of this
, but I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's because the use of this in the state-machine functions. Agree on the use of blank lines 👍
Description
This PR adds a finite state machine that tracks and protects all calls from baseStack to peerConnection.
This PR also reorganizes many of the functions in baseStack. There are now two structures
enqueuedCalls
andprotectedCalls
.protectedCalls
are only called fromPeerConnectionFsm
enqueuedCalls
can be called from anywhere else and they are protected by aFunctionQueue
.[] It needs and includes Unit Tests
Changes in Client or Server public APIs
[] It includes documentation for these changes in
/doc
.