Merge pull request #52 from MaybeRex/master

added triggers for 'close' and 'error'

looks good
This commit is contained in:
Brandon Nozaki Miller 2015-12-02 10:07:35 -08:00
commit ffd358b5ed

View file

@ -102,6 +102,8 @@ function connect(){
'error', 'error',
function(err){ function(err){
client.log('\n\n######\nerror: '.error, err); client.log('\n\n######\nerror: '.error, err);
client.trigger('error', err);
} }
); );
@ -110,7 +112,7 @@ function connect(){
function(){ function(){
client.trigger('connect'); client.trigger('connect');
client.retriesRemaining=client.config.maxRetries; client.retriesRemaining=client.config.maxRetries;
client.log('retrying reset') client.log('retrying reset');
} }
); );
@ -123,6 +125,7 @@ function connect(){
client.config.stopRetrying || client.retriesRemaining<1 client.config.stopRetrying || client.retriesRemaining<1
){ ){
client.trigger('disconnect');
client.log( client.log(
client.config.id.variable, client.config.id.variable,
'exceeded connection rety amount of'.warn, 'exceeded connection rety amount of'.warn,
@ -130,6 +133,7 @@ function connect(){
); );
client.socket.destroy(); client.socket.destroy();
client.trigger('destroy');
client=undefined; client=undefined;
return; return;