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

check for empty occupants fixed #264

Closed
wants to merge 1 commit into from

Conversation

czadamToptal
Copy link

For me that check always returned false and the room never got cleaned up properly

For me that check always returned false and the room never got cleaned up properly
@@ -76,7 +76,7 @@ io.on("connection", socket => {
const occupants = rooms[curRoom].occupants;
socket.to(curRoom).broadcast.emit("occupantsChanged", { occupants });

if (occupants == {}) {
if (JSON.stringify(occupants) === JSON.stringify({})) {
Copy link
Member

Choose a reason for hiding this comment

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

You're right

occupants={}
occupants == {}
false

Instead of jsonify to do a comparison.
if (Object.keys(occupants).length === 0)
should be better, this is what open-easyrtc more or less do via the underscore size function.
Can you please test that and tell me if it's good for you?

Copy link
Author

Choose a reason for hiding this comment

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

if (Object.keys(occupants).length === 0)
works as well

@vincentfretin
Copy link
Member

Thank you for the contribution! If you can test the change I proposed and update the PR, it would be great.
Otherwise I will test that myself later.

@vincentfretin
Copy link
Member

Thanks I fixed it in 6606e14

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.

None yet

2 participants