Permalink
Browse files

Clean up ping code.

  • Loading branch information...
1 parent a9659df commit faa1f11c288e813d60237e3e08e673a7781cb939 @jcoglan jcoglan committed Feb 11, 2012
Showing with 4 additions and 8 deletions.
  1. +1 −2 lib/faye/websocket.js
  2. +3 −6 lib/faye/websocket/hybi_parser.js
View
@@ -64,8 +64,7 @@ var WebSocket = function(request, socket, head, supportedProtos, options) {
if (this._ping)
this._pingLoop = setInterval(function() {
self._pingId += 1;
- var id = self._pingId.toString();
- self.ping(id);
+ self.ping(self._pingId.toString());
}, this._ping * 1000);
this._stream.addListener('data', function(data) {
@@ -319,13 +319,10 @@ var instance = {
else if (opcode === this.OPCODES.pong) {
var callbacks = this._pingCallbacks,
message = this._encode(payload),
- callback;
+ callback = callbacks[message];
- if (callbacks) {
- callback = callbacks[message];
- delete callbacks[message];
- if (callback) callback[0].call(callback[1]);
- }
+ delete callbacks[message];
+ if (callback) callback[0].call(callback[1]);
}
},

0 comments on commit faa1f11

Please sign in to comment.