fixing formatting issues and best practices

This commit is contained in:
Brandon Nozaki Miller 2016-01-09 21:48:03 -08:00
parent 7b0cc85fa1
commit 45cf879345

View file

@ -54,14 +54,16 @@ var ipc = {
} }
function log(){ function log(){
if(ipc.config.silent) if(ipc.config.silent){
return; return;
}
var args=Array.prototype.slice.call(arguments); var args=Array.prototype.slice.call(arguments);
for(var i=0, count=args.length; i<count; i++){ for(var i=0, count=args.length; i<count; i++){
if(typeof args[i] != 'object') if(typeof args[i] != 'object'){
continue; continue;
}
args[i]=util.inspect(args[i],{colors:true}); args[i]=util.inspect(args[i],{colors:true});
} }
@ -72,19 +74,21 @@ function log(){
} }
function disconnect(id){ function disconnect(id){
if(!ipc.of[id]) if(!ipc.of[id]){
return; return;
}
ipc.of[id].config.stopRetrying=true; ipc.of[id].config.stopRetrying=true;
ipc.of[id].off('*'); ipc.of[id].off('*');
if(ipc.of[id].socket){ if(ipc.of[id].socket){
if(ipc.of[id].socket.destroy) if(ipc.of[id].socket.destroy){
ipc.of[id].socket.destroy(); ipc.of[id].socket.destroy();
}
} }
delete ipc.of[id]; delete ipc.of[id];
} };
function serve(path,callback){ function serve(path,callback){
if(typeof path=='function'){ if(typeof path=='function'){
@ -100,8 +104,9 @@ function serve(path,callback){
path=ipc.config.socketRoot+ipc.config.appspace+ipc.config.id; path=ipc.config.socketRoot+ipc.config.appspace+ipc.config.id;
} }
if(!callback) if(!callback){
callback=function(){}; callback=function(){};
}
ipc.server=new Server( ipc.server=new Server(
path, path,
@ -167,9 +172,9 @@ function serveNet(host,port,UDPType,callback){
UDPType=false; UDPType=false;
} }
if(!callback) if(!callback){
callback=function(){}; callback=function(){};
}
ipc.server=new Server( ipc.server=new Server(
host, host,
@ -178,8 +183,9 @@ function serveNet(host,port,UDPType,callback){
port port
); );
if(UDPType) if(UDPType){
ipc.server[UDPType]=true; ipc.server[UDPType]=true;
}
ipc.server.on( ipc.server.on(
'start', 'start',
@ -193,8 +199,9 @@ function connect(id,path,callback){
path=false; path=false;
} }
if(!callback) if(!callback){
callback=function(){}; callback=function(){};
}
if(!id){ if(!id){
ipc.log( ipc.log(
@ -279,8 +286,9 @@ function connectNet(id,host,port,callback){
UDPType=callback; UDPType=callback;
callback=false; callback=false;
} }
if(!callback) if(!callback){
callback=function(){}; callback=function(){};
}
if(ipc.of[id]){ if(ipc.of[id]){
if(!ipc.of[id].socket.destroyed){ if(!ipc.of[id].socket.destroyed){