Skip to content
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

Merged
merged 3 commits into from
Mar 26, 2019

Conversation

lodoyun
Copy link
Contributor

@lodoyun lodoyun commented Mar 25, 2019

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 and protectedCalls.
protectedCalls are only called from PeerConnectionFsm
enqueuedCalls can be called from anywhere else and they are protected by a FunctionQueue.

[] It needs and includes Unit Tests

Changes in Client or Server public APIs

[] It includes documentation for these changes in /doc.

Copy link
Contributor

@jcague jcague left a 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' },
Copy link
Contributor

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) => {
Copy link
Contributor

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();
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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 👍

@lodoyun lodoyun merged commit 31fec21 into lynckia:master Mar 26, 2019
@lodoyun lodoyun deleted the add/baseStackFsm branch March 26, 2019 12:12
Arri98 pushed a commit to Arri98/licode that referenced this pull request Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants