SpeCT/node-c2dm — pull request #23 by TauZero (2012-10-22 14:22:22+00:00)
Title: Remove 'sent' listener before calling self.send again to prevent double cb

The Issue: C2DM.send accepts the packet and a callback, cb. If cb is provided, it sets a once listener on 'this' for the 'sent' event. When the client needs to update auth, it emits a 'token' event and then calls self.send with the same packet and cb. This was causing a second this.once('sent',cb) to be set, making the callback fire twice when 'sent' is finally emitted.

The Fix: When renewing the token, used removeListner to clear the 'sent' cb listener before calling self.send again.