Comparing version
{ | ||
"name": "ricochet", | ||
"version": "0.3.14", | ||
"version": "0.3.15", | ||
"description": "Pub/Sub Framework for building robust TCP transport layers in node.js applications ", | ||
@@ -5,0 +5,0 @@ "main": "ricochet.js", |
@@ -49,3 +49,3 @@ 'use strict'; | ||
if(err){ | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('sendError', { | ||
@@ -56,3 +56,3 @@ Error: err.Error, | ||
}); | ||
}catch(e){} | ||
}); | ||
} | ||
@@ -65,3 +65,3 @@ return cb(err); | ||
if(err){ | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('receiveError', { | ||
@@ -72,3 +72,3 @@ Error: err.Error, | ||
}); | ||
}catch(e){} | ||
}); | ||
} | ||
@@ -115,5 +115,5 @@ return cb(err); | ||
if(this.helpers.has(data, ['publicKey', 'authKey', 'authStamp'])){ | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('message', data); | ||
}catch(e){} | ||
}); | ||
return this.socket.write(JSON.stringify(data) + self.config.delimiters.message, 'utf8', callback); | ||
@@ -163,7 +163,7 @@ } | ||
if(results.code === 'message_timeout'){ | ||
try{ | ||
process.nextTick(function(){ | ||
data.events.emit('timeout', { | ||
local: false | ||
}); | ||
}catch(e){} | ||
}); | ||
} | ||
@@ -180,7 +180,7 @@ self.cleanupMsg(msg.headers.id); | ||
timeout = setTimeout(function(){ | ||
try{ | ||
process.nextTick(function(){ | ||
data.events.emit('timeout', { | ||
local: true | ||
}); | ||
}catch(e){} | ||
}); | ||
}, msg.headers.timeout + self.config.timeouts.latencyBuffer); | ||
@@ -216,3 +216,3 @@ } | ||
self.status.groups = msg.groups; | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('ready', { | ||
@@ -222,9 +222,9 @@ channel: msg.channel, | ||
}); | ||
}catch(e){} | ||
}); | ||
}else{ | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('authFail', { | ||
message: msg | ||
}); | ||
}catch(e){} | ||
}); | ||
self.socket.end(); | ||
@@ -262,15 +262,15 @@ } | ||
case "message": | ||
try{ | ||
process.nextTick(function(){ | ||
if(!self.handles.emit(msg.headers.handle, msg.body, msg)){ | ||
self.handles.emit('message_nothandled', msg); | ||
} | ||
}catch(e){} | ||
}); | ||
break; | ||
case "request": | ||
var handler = self.replyHandler(msg); | ||
try{ | ||
process.nextTick(function(){ | ||
if(!self.handles.emit(msg.headers.handle, msg.body, handler, msg)){ | ||
self.handles.emit('message_nothandled', msg, handler); | ||
} | ||
}catch(e){} | ||
}); | ||
break; | ||
@@ -285,3 +285,3 @@ case "reply": | ||
if(self.msgs[msg.headers.id].events){ | ||
try{ | ||
process.nextTick(function(){ | ||
if(msg.headers.status === 'response'){ | ||
@@ -292,3 +292,3 @@ self.msgs[msg.headers.id].events.emit(msg.headers.status, msg.body.error, msg.body.data); | ||
} | ||
}catch(e){} | ||
}); | ||
} | ||
@@ -430,3 +430,3 @@ break; | ||
self.status.connected = true; | ||
try{ | ||
process.nextTick(function(){ | ||
if(firstConnect){ | ||
@@ -437,3 +437,3 @@ self.emit('connected'); | ||
} | ||
}catch(e){} | ||
}); | ||
// send authentication | ||
@@ -440,0 +440,0 @@ self.sendAuth(); |
@@ -32,5 +32,5 @@ 'use strict'; | ||
err.raw = data; | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('messageError', err); | ||
}catch(e){} | ||
}); | ||
} | ||
@@ -113,7 +113,7 @@ return cb(); | ||
} | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('clientDisconnected', { | ||
id: id | ||
}); | ||
}catch(e){} | ||
}); | ||
delete self.clients[id]; | ||
@@ -145,3 +145,3 @@ } | ||
try{ | ||
process.nextTick(function(){ | ||
this.emit('clientConnected', { | ||
@@ -151,9 +151,9 @@ id: client.id, | ||
}); | ||
}catch(e){} | ||
}); | ||
setTimeout(function(){ | ||
if(self.clients[client.id] && !self.clients[client.id].auth){ | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('clientAuthFail', self.helpers.error('auth_timeout', {ip: client.remoteAddress})); | ||
}catch(e){} | ||
}); | ||
return self.destroyClient(client.id); | ||
@@ -192,5 +192,5 @@ } | ||
}; | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('clientInput', data); | ||
}catch(e){} | ||
}); | ||
return self.bufferQueue.push(data); | ||
@@ -275,12 +275,12 @@ }); | ||
if(err){ | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('clientAuthFail', err); | ||
}catch(e){} | ||
}); | ||
self.destroyClient(data.id); | ||
}else{ | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('clientReady', { | ||
id: data.id | ||
}); | ||
}catch(e){} | ||
}); | ||
} | ||
@@ -352,3 +352,3 @@ return callback(err); // remove error to prevent wrong event | ||
try{ | ||
process.nextTick(function(){ | ||
self.emit('message', { | ||
@@ -358,3 +358,3 @@ id: clientMap[data.message.headers.to], | ||
}); | ||
}catch(e){} | ||
}); | ||
return callback(); | ||
@@ -361,0 +361,0 @@ }); |
42334
0.72%