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

Add timeout to acknowledgdement handling #16

Open
mucaho opened this issue Jul 16, 2015 · 0 comments
Open

Add timeout to acknowledgdement handling #16

mucaho opened this issue Jul 16, 2015 · 0 comments
Labels

Comments

@mucaho
Copy link
Owner

mucaho commented Jul 16, 2015

In npm_crafty.matchmaking.js

ServerMatchmaker.prototype.notify = function(room, slot, socket, message, notifyCallback) {
    var self = this;

    var socketIds = Object.keys(room.takenSpots);
    var ackedIds = 0;
    for (var i = 0; i < socketIds.length; ++i) {
        self.sockets[socketIds[i]].socket.emit(message, slot, function(data) {
            ackedIds++;
            if (ackedIds >= socketIds.length) {
                console.log(message, "@", slot);
                notifyCallback(room.userData, socket, slot, room.openSlots);
            }
        });
    }
};

Two clients could disconnect at the same time, hence acknowledgement/callback-function for first client leaving will never get the required amount of ackedIds.
Add a timeout of ~1 sec before proceeding with sending notifications.

@mucaho mucaho added the bug label Jul 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant