{"issue":{"state":"open","pull_request":{"diff_url":null,"html_url":null,"patch_url":null},"milestone":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/6937c835f5298f08fbb1345c66564365?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"6937c835f5298f08fbb1345c66564365","url":"https://api.github.com/users/hjesbguhs","login":"hjesbguhs","id":1196757},"assignee":null,"updated_at":"2011-11-15T14:47:35Z","labels":[],"closed_at":null,"comments":0,"url":"https://api.github.com/repos/LearnBoost/socket.io/issues/645","body":"When using `socket.send()` instead of `socket.emit()` the callbacks don't work.\r\n\r\nclient:\r\n\r\n```javascript\r\nsocket.send('test',function(data){\r\n...\r\n});\r\n```\r\n\r\nserver:\r\n\r\n```javascript\r\nsocket.on('message',function(data,cb){\r\n//cb is undefined\r\n});\r\n```\r\n\r\nI got it working with these changes. However I'm not quite sure if it's a bug or you just shouldn't use .send with callbacks.\r\n\r\nnode (in `Socket.prototype.send`) replace:\r\n\r\n```javascript\r\n...\r\n  if (fn) {\r\n    packet.id = ++this.ackPackets;\r\n    packet.ack = true;\r\n    this.acks[packet.id] = fn;\r\n  }\r\n...\r\n```\r\n\r\nwith\r\n\r\n```javascript\r\n...\r\n  if ('function' == typeof fn) {\r\n    packet.id = ++this.ackPackets;\r\n    packet.ack = fn.length ? 'data' : true;\r\n    this.acks[packet.id] = fn;\r\n  }\r\n...\r\n```\r\n\r\nbrowser (in `SocketNamespace.prototype.send`):\r\n\r\n```javascript\r\n...\r\n    if ('function' == typeof fn) {\r\n      packet.id = ++this.ackPackets;\r\n      packet.ack = true;\r\n      this.acks[packet.id] = fn;\r\n    }\r\n...\r\n```\r\n\r\nwith\r\n\r\n```javascript\r\n...\r\n    if ('function' == typeof fn) {\r\n      packet.id = ++this.ackPackets;\r\n      packet.ack = fn.length ? 'data' : true;\r\n      this.acks[packet.id] = fn;\r\n    }\r\n...\r\n```\r\n","html_url":"https://github.com/LearnBoost/socket.io/issues/645","title":"socket.send() callbacks don't work","number":645,"id":2244817,"created_at":"2011-11-15T14:47:35Z"},"action":"opened"}