Skip to content

Commit

Permalink
SubEmitterSocket should apply listener with self
Browse files Browse the repository at this point in the history
This commit makes `SubEmitterSocket.prototype.onmessage` apply its
listener method with `self` rather than `this`. This behaviour is
consistent with that of the `SubEmitter`, and provides access to the
underlying socket (rather than the message buffer) in the listener.
  • Loading branch information
lfk committed Jun 19, 2015
1 parent 92ebe82 commit f841050
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/sockets/sub-emitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function SubEmitterSocket() {
* @api private
*/

SubEmitterSocket.prototype.onmessage = function(){
SubEmitterSocket.prototype.onmessage = function(sock){
var listeners = this.listeners;
var self = this;

Expand All @@ -49,7 +49,7 @@ SubEmitterSocket.prototype.onmessage = function(){
var m = listener.re.exec(topic);
if (!m) continue;

listener.fn.apply(this, m.slice(1).concat(msg.args));
listener.fn.apply(self, m.slice(1).concat(msg.args));
}
}
};
Expand Down

0 comments on commit f841050

Please sign in to comment.