Skip to content

Commit

Permalink
Merge pull request #194 from 3rd-Eden/master
Browse files Browse the repository at this point in the history
Handle errors and advice
  • Loading branch information
rauchg committed Jun 19, 2011
2 parents 412341f + 59355dd commit 0ba64df
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@
this.acks[packet.ackId].apply(this, packet.args);
delete this.acks[packet.ackId];
}

case 'error':
if (packet.advice){
this.socket.onError(packet);
} else {
this.$emit('error', packet.reason);
}
}
};

Expand Down
9 changes: 8 additions & 1 deletion lib/socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,14 @@
*/

Socket.prototype.onError = function (err) {
this.publish('error', err);
if (err && err.advice){
if (err.advice === 'reconnect'){
this.disconnect();
this.reconnect();
}
}

this.publish('error', err && err.reason ? err.reason : err);
};

/**
Expand Down

0 comments on commit 0ba64df

Please sign in to comment.