Created
April 18, 2012 12:56
-
-
Save develar/2413408 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ecd7497ba3b8343e9dfb78e8afc395ac0a47b1fe Mon Sep 17 00:00:00 2001 | |
From: develar <[email protected]> | |
Date: Wed, 18 Apr 2012 16:52:37 +0400 | |
Subject: [PATCH] ack on event | |
--- | |
dist/socket.io.js | 29 +++++++++-------------------- | |
1 file changed, 9 insertions(+), 20 deletions(-) | |
diff --git a/dist/socket.io.js b/dist/socket.io.js | |
index f2c6a38..0be1f39 100644 | |
--- a/dist/socket.io.js | |
+++ b/dist/socket.io.js | |
@@ -2155,15 +2155,6 @@ | |
SocketNamespace.prototype.onPacket = function (packet) { | |
var self = this; | |
- | |
- function ack () { | |
- self.packet({ | |
- type: 'ack' | |
- , args: io.util.toArray(arguments) | |
- , ackId: packet.id | |
- }); | |
- }; | |
- | |
switch (packet.type) { | |
case 'connect': | |
this.$emit('connect'); | |
@@ -2179,10 +2170,17 @@ | |
case 'message': | |
case 'json': | |
- var params = ['message', packet.data]; | |
+ case 'event': | |
+ var params = packet.type == 'event' ? [packet.name].concat(packet.args) : ['message', packet.data]; | |
if (packet.ack == 'data') { | |
- params.push(ack); | |
+ params.push(function ack() { | |
+ self.packet({ | |
+ type: 'ack', | |
+ args: io.util.toArray(arguments), | |
+ ackId: packet.id | |
+ }); | |
+ }); | |
} else if (packet.ack) { | |
this.packet({ type: 'ack', ackId: packet.id }); | |
} | |
@@ -2190,15 +2188,6 @@ | |
this.$emit.apply(this, params); | |
break; | |
- case 'event': | |
- var params = [packet.name].concat(packet.args); | |
- | |
- if (packet.ack == 'data') | |
- params.push(ack); | |
- | |
- this.$emit.apply(this, params); | |
- break; | |
- | |
case 'ack': | |
if (this.acks[packet.ackId]) { | |
this.acks[packet.ackId].apply(this, packet.args); | |
-- | |
1.7.10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment