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

remove multiple ready events. #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions step-06/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ io.sockets.on('connection', function(socket) {
socket.emit('created', room, socket.id);
} else if (numClients === 1) {
log('Client ID ' + socket.id + ' joined room ' + room);
// io.sockets.in(room).emit('join', room);
socket.join(room);
socket.emit('joined', room, socket.id);
io.sockets.in(room).emit('ready', room);
socket.broadcast.emit('ready', room);
} else { // max two clients
socket.emit('full', room);
}
Expand Down
1 change: 0 additions & 1 deletion step-06/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ socket.on('created', function(room, clientId) {
socket.on('joined', function(room, clientId) {
console.log('This peer has joined room', room, 'with client ID', clientId);
isInitiator = false;
createPeerConnection(isInitiator, configuration);
Copy link
Contributor

@nitobuendia nitobuendia Jun 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@druuu Was this causing issues too or what's the logic to change it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: It works; just want to be sure we are not changing more than we should.

Copy link
Author

@druuu druuu Jun 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nitobuendia
the changes are made because it looks a bit confusing, here we go:

before the changes:
user1 joins, 'isinitiator' is set to true for user1.
user2 joins, 'isinitiator' is set to false for user2 and also peerconnection is established for user2
user2 sends READY event, now user1 peerconnection is created

After the changes:
user1 joins, 'isinitiator' is set to true for user1.
user2 joins, 'isinitiator' is set to false for user2.
user2 sends READY event, peerconnection is created for both user1 and user2.

So, it looks more simple in the second case.
If you dont want these changes, i can send you another PR, or you can just remove https://github.com/googlecodelabs/webrtc-web/blob/master/step-06/index.js#L45

thank you for these tutorials, they are really helpful and simple.

grabWebCamVideo();
});

Expand Down