cleaning up format
This commit is contained in:
parent
f176a01d1b
commit
6278fd472b
20 changed files with 971 additions and 951 deletions
|
@ -38,4 +38,4 @@ ipc.connectToNet(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(ipc);
|
console.log(ipc);
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Message = require('js-message');
|
const parser={
|
||||||
|
parse : parseDataEvents,
|
||||||
|
format : formatData,
|
||||||
|
delimiter : '\f'
|
||||||
|
};
|
||||||
|
|
||||||
function formatData(message){
|
function formatData(message){
|
||||||
if(!message.data){
|
if(!message.data){
|
||||||
|
@ -20,10 +24,4 @@ function parseDataEvents(data){
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
const parser={
|
|
||||||
parse : parseDataEvents,
|
|
||||||
format : formatData,
|
|
||||||
delimiter : '\f'
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports=parser;
|
module.exports=parser;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
'use strict';
|
||||||
|
|
||||||
const net = require('net'),
|
const net = require('net'),
|
||||||
tls = require('tls'),
|
tls = require('tls'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
|
@ -72,16 +74,16 @@ function init(path,config,log,port){
|
||||||
sockets : [],
|
sockets : [],
|
||||||
emit : emit,
|
emit : emit,
|
||||||
broadcast : broadcast,
|
broadcast : broadcast,
|
||||||
onStart : function(socket){
|
onStart : function onStart(socket){
|
||||||
this.trigger(
|
this.trigger(
|
||||||
'start',
|
'start',
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
stop:function(){
|
stop:function stop(){
|
||||||
server.server.close();
|
server.server.close();
|
||||||
},
|
},
|
||||||
start : function(){
|
start : function start(){
|
||||||
if(!this.path){
|
if(!this.path){
|
||||||
server.log('Socket Server Path not specified, refusing to start'.warn);
|
server.log('Socket Server Path not specified, refusing to start'.warn);
|
||||||
return;
|
return;
|
||||||
|
@ -89,244 +91,240 @@ function init(path,config,log,port){
|
||||||
|
|
||||||
fs.unlink(
|
fs.unlink(
|
||||||
this.path,
|
this.path,
|
||||||
(
|
function () {
|
||||||
function(server){
|
server.log('starting server on '.debug,server.path.variable,((server.port)?':'+server.port:'').variable);
|
||||||
return function () {
|
|
||||||
server.log('starting server on '.debug,server.path.variable,((server.port)?':'+server.port:'').variable);
|
|
||||||
|
|
||||||
if(!server.udp4 && !server.udp6){
|
if(!server.udp4 && !server.udp6){
|
||||||
if(!server.config.tls){
|
if(!server.config.tls){
|
||||||
server.server=net.createServer(
|
server.server=net.createServer(
|
||||||
serverCreated
|
serverCreated
|
||||||
);
|
|
||||||
}else{
|
|
||||||
server.log('starting TLS server'.debug,server.config.tls);
|
|
||||||
if(server.config.tls.private){
|
|
||||||
server.config.tls.key=fs.readFileSync(server.config.tls.private);
|
|
||||||
}else{
|
|
||||||
server.config.tls.key=fs.readFileSync(__dirname+'/../local-node-ipc-certs/private/server.key');
|
|
||||||
}
|
|
||||||
if(server.config.tls.public){
|
|
||||||
server.config.tls.cert=fs.readFileSync(server.config.tls.public);
|
|
||||||
}else{
|
|
||||||
server.config.tls.cert=fs.readFileSync(__dirname+'/../local-node-ipc-certs/server.pub');
|
|
||||||
}
|
|
||||||
if(server.config.tls.dhparam){
|
|
||||||
server.config.tls.dhparam=fs.readFileSync(server.config.tls.dhparam);
|
|
||||||
}
|
|
||||||
if(server.config.tls.trustedConnections){
|
|
||||||
if(typeof server.config.tls.trustedConnections === 'string'){
|
|
||||||
server.config.tls.trustedConnections=[server.config.tls.trustedConnections];
|
|
||||||
}
|
|
||||||
server.config.tls.ca=[];
|
|
||||||
for(let i=0; i<server.config.tls.trustedConnections.length; i++){
|
|
||||||
server.config.tls.ca.push(
|
|
||||||
fs.readFileSync(server.config.tls.trustedConnections[i])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
server.server=tls.createServer(
|
|
||||||
server.config.tls,
|
|
||||||
serverCreated
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
function UDPWrite(message,socket){
|
|
||||||
let data=new Buffer(message, server.config.encoding);
|
|
||||||
server.server.send(
|
|
||||||
data,
|
|
||||||
0,
|
|
||||||
data.length,
|
|
||||||
socket.port,
|
|
||||||
socket.address,
|
|
||||||
function(err, bytes) {
|
|
||||||
if(err){
|
|
||||||
server.log('error writing data to socket'.warn,err);
|
|
||||||
server.trigger(
|
|
||||||
'error',
|
|
||||||
function(err){
|
|
||||||
server.trigger('error',err);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
server.server=dgram.createSocket(
|
|
||||||
((server.udp4)? 'udp4':'udp6')
|
|
||||||
);
|
|
||||||
server.server.write=UDPWrite;
|
|
||||||
server.server.on(
|
|
||||||
'listening',
|
|
||||||
function () {
|
|
||||||
serverCreated(server.server);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
server.server.on(
|
|
||||||
'error',
|
|
||||||
function(err){
|
|
||||||
server.log('server error'.warn,err);
|
|
||||||
|
|
||||||
server.trigger(
|
|
||||||
'error',
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
}else{
|
||||||
server.server.maxConnections=server.config.maxConnections;
|
server.log('starting TLS server'.debug,server.config.tls);
|
||||||
|
if(server.config.tls.private){
|
||||||
function serverCreated(socket) {
|
server.config.tls.key=fs.readFileSync(server.config.tls.private);
|
||||||
server.sockets.push(socket);
|
}else{
|
||||||
|
server.config.tls.key=fs.readFileSync(__dirname+'/../local-node-ipc-certs/private/server.key');
|
||||||
if(socket.setEncoding){
|
}
|
||||||
socket.setEncoding(server.config.encoding);
|
if(server.config.tls.public){
|
||||||
|
server.config.tls.cert=fs.readFileSync(server.config.tls.public);
|
||||||
|
}else{
|
||||||
|
server.config.tls.cert=fs.readFileSync(__dirname+'/../local-node-ipc-certs/server.pub');
|
||||||
|
}
|
||||||
|
if(server.config.tls.dhparam){
|
||||||
|
server.config.tls.dhparam=fs.readFileSync(server.config.tls.dhparam);
|
||||||
|
}
|
||||||
|
if(server.config.tls.trustedConnections){
|
||||||
|
if(typeof server.config.tls.trustedConnections === 'string'){
|
||||||
|
server.config.tls.trustedConnections=[server.config.tls.trustedConnections];
|
||||||
}
|
}
|
||||||
|
server.config.tls.ca=[];
|
||||||
server.log('## socket connection to server detected ##'.rainbow);
|
for(let i=0; i<server.config.tls.trustedConnections.length; i++){
|
||||||
socket.on(
|
server.config.tls.ca.push(
|
||||||
'close',
|
fs.readFileSync(server.config.tls.trustedConnections[i])
|
||||||
function(socket){
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
server.server=tls.createServer(
|
||||||
|
server.config.tls,
|
||||||
|
serverCreated
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
function UDPWrite(message,socket){
|
||||||
|
let data=new Buffer(message, server.config.encoding);
|
||||||
|
server.server.send(
|
||||||
|
data,
|
||||||
|
0,
|
||||||
|
data.length,
|
||||||
|
socket.port,
|
||||||
|
socket.address,
|
||||||
|
function(err, bytes) {
|
||||||
|
if(err){
|
||||||
|
server.log('error writing data to socket'.warn,err);
|
||||||
server.trigger(
|
server.trigger(
|
||||||
'close',
|
'error',
|
||||||
socket
|
function(err){
|
||||||
|
server.trigger('error',err);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
socket.on(
|
server.server=dgram.createSocket(
|
||||||
'error',
|
((server.udp4)? 'udp4':'udp6')
|
||||||
function(err){
|
);
|
||||||
server.log('server socket error'.warn,err);
|
server.server.write=UDPWrite;
|
||||||
|
server.server.on(
|
||||||
|
'listening',
|
||||||
|
function () {
|
||||||
|
serverCreated(server.server);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
server.trigger('error',err);
|
server.server.on(
|
||||||
}
|
'error',
|
||||||
);
|
function(err){
|
||||||
|
server.log('server error'.warn,err);
|
||||||
|
|
||||||
socket.on(
|
server.trigger(
|
||||||
'data',
|
'error',
|
||||||
function(data,UDPSocket){
|
err
|
||||||
let sock=((server.udp4 || server.udp6)? UDPSocket : socket);
|
);
|
||||||
if(server.config.rawBuffer){
|
}
|
||||||
data=new Buffer(data,this.encoding);
|
);
|
||||||
server.trigger(
|
|
||||||
'data',
|
|
||||||
data,
|
|
||||||
sock
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.ipcBuffer){
|
server.server.maxConnections=server.config.maxConnections;
|
||||||
this.ipcBuffer='';
|
|
||||||
}
|
|
||||||
|
|
||||||
data=(this.ipcBuffer+=data);
|
function serverCreated(socket) {
|
||||||
|
server.sockets.push(socket);
|
||||||
|
|
||||||
if(data.slice(-1)!=eventParser.delimiter || data.indexOf(eventParser.delimiter) == -1){
|
if(socket.setEncoding){
|
||||||
server.log('Implementing larger buffer for this socket message. You may want to consider smaller messages'.notice);
|
socket.setEncoding(server.config.encoding);
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.ipcBuffer='';
|
|
||||||
|
|
||||||
data=eventParser.parse(data);
|
|
||||||
|
|
||||||
while(data.length>0){
|
|
||||||
let message=new Message;
|
|
||||||
message.load(data.shift());
|
|
||||||
|
|
||||||
server.log('received event of : '.debug,message.type.data,message.data);
|
|
||||||
|
|
||||||
if(message.data.id)
|
|
||||||
sock.id=message.data.id;
|
|
||||||
|
|
||||||
server.trigger(
|
|
||||||
message.type,
|
|
||||||
message.data,
|
|
||||||
sock
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
socket.on(
|
|
||||||
'message',
|
|
||||||
function(msg,rinfo) {
|
|
||||||
if (!rinfo){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
server.log('Received UDP message from '.debug, rinfo.address.variable, rinfo.port);
|
|
||||||
let data;
|
|
||||||
|
|
||||||
if(server.config.rawSocket){
|
|
||||||
data=new Buffer(msg,this.encoding);
|
|
||||||
}else{
|
|
||||||
data=msg.toString();
|
|
||||||
}
|
|
||||||
socket.emit('data',data,rinfo);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
|
server.log('## socket connection to server detected ##'.rainbow);
|
||||||
|
socket.on(
|
||||||
|
'close',
|
||||||
|
function(socket){
|
||||||
server.trigger(
|
server.trigger(
|
||||||
'connect',
|
'close',
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
socket.on(
|
||||||
|
'error',
|
||||||
|
function(err){
|
||||||
|
server.log('server socket error'.warn,err);
|
||||||
|
|
||||||
|
server.trigger('error',err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
socket.on(
|
||||||
|
'data',
|
||||||
|
function(data,UDPSocket){
|
||||||
|
let sock=((server.udp4 || server.udp6)? UDPSocket : socket);
|
||||||
if(server.config.rawBuffer){
|
if(server.config.rawBuffer){
|
||||||
|
data=new Buffer(data,this.encoding);
|
||||||
|
server.trigger(
|
||||||
|
'data',
|
||||||
|
data,
|
||||||
|
sock
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function started(socket){
|
if(!this.ipcBuffer){
|
||||||
server.onStart(socket);
|
this.ipcBuffer='';
|
||||||
}
|
|
||||||
|
|
||||||
if(!port){
|
|
||||||
server.log('starting server as'.debug, 'Unix || Windows Socket'.variable);
|
|
||||||
if (process.platform ==='win32'){
|
|
||||||
server.path = server.path.replace(/^\//, '');
|
|
||||||
server.path = server.path.replace(/\//g, '-');
|
|
||||||
server.path= '\\\\.\\pipe\\'+server.path;
|
|
||||||
}
|
|
||||||
|
|
||||||
server.server.listen(
|
|
||||||
server.path,
|
|
||||||
started
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!server.udp4 && !server.udp6){
|
|
||||||
server.log('starting server as'.debug, (server.config.tls?'TLS':'TCP').variable);
|
|
||||||
server.server.listen(
|
|
||||||
server.port,
|
|
||||||
server.path,
|
|
||||||
started
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
server.log('starting server as'.debug,((server.udp4)? 'udp4':'udp6').variable);
|
|
||||||
server.server.bind(
|
|
||||||
server.port,
|
|
||||||
server.path
|
|
||||||
);
|
|
||||||
|
|
||||||
started(
|
|
||||||
{
|
|
||||||
address : server.path,
|
|
||||||
port : server.port
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
};
|
data=(this.ipcBuffer+=data);
|
||||||
|
|
||||||
|
if(data.slice(-1)!=eventParser.delimiter || data.indexOf(eventParser.delimiter) == -1){
|
||||||
|
server.log('Implementing larger buffer for this socket message. You may want to consider smaller messages'.notice);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ipcBuffer='';
|
||||||
|
|
||||||
|
data=eventParser.parse(data);
|
||||||
|
|
||||||
|
while(data.length>0){
|
||||||
|
let message=new Message;
|
||||||
|
message.load(data.shift());
|
||||||
|
|
||||||
|
server.log('received event of : '.debug,message.type.data,message.data);
|
||||||
|
|
||||||
|
if(message.data.id)
|
||||||
|
sock.id=message.data.id;
|
||||||
|
|
||||||
|
server.trigger(
|
||||||
|
message.type,
|
||||||
|
message.data,
|
||||||
|
sock
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
socket.on(
|
||||||
|
'message',
|
||||||
|
function(msg,rinfo) {
|
||||||
|
if (!rinfo){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
server.log('Received UDP message from '.debug, rinfo.address.variable, rinfo.port);
|
||||||
|
let data;
|
||||||
|
|
||||||
|
if(server.config.rawSocket){
|
||||||
|
data=new Buffer(msg,this.encoding);
|
||||||
|
}else{
|
||||||
|
data=msg.toString();
|
||||||
|
}
|
||||||
|
socket.emit('data',data,rinfo);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
server.trigger(
|
||||||
|
'connect',
|
||||||
|
socket
|
||||||
|
);
|
||||||
|
|
||||||
|
if(server.config.rawBuffer){
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)(this)
|
|
||||||
|
function started(socket){
|
||||||
|
server.onStart(socket);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!port){
|
||||||
|
server.log('starting server as'.debug, 'Unix || Windows Socket'.variable);
|
||||||
|
if (process.platform ==='win32'){
|
||||||
|
server.path = server.path.replace(/^\//, '');
|
||||||
|
server.path = server.path.replace(/\//g, '-');
|
||||||
|
server.path= '\\\\.\\pipe\\'+server.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
server.server.listen(
|
||||||
|
server.path,
|
||||||
|
started
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!server.udp4 && !server.udp6){
|
||||||
|
server.log('starting server as'.debug, (server.config.tls?'TLS':'TCP').variable);
|
||||||
|
server.server.listen(
|
||||||
|
server.port,
|
||||||
|
server.path,
|
||||||
|
started
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
server.log('starting server as'.debug,((server.udp4)? 'udp4':'udp6').variable);
|
||||||
|
server.server.bind(
|
||||||
|
server.port,
|
||||||
|
server.path
|
||||||
|
);
|
||||||
|
|
||||||
|
started(
|
||||||
|
{
|
||||||
|
address : server.path,
|
||||||
|
port : server.port
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
12
node-ipc.js
12
node-ipc.js
|
@ -106,7 +106,7 @@ function serve(path,callback){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!callback){
|
if(!callback){
|
||||||
callback=function(){};
|
callback=emptyCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.server=new Server(
|
ipc.server=new Server(
|
||||||
|
@ -121,6 +121,10 @@ function serve(path,callback){
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function emptyCallback(){
|
||||||
|
//Do Nothing
|
||||||
|
}
|
||||||
|
|
||||||
function serveNet(host,port,UDPType,callback){
|
function serveNet(host,port,UDPType,callback){
|
||||||
if(typeof host=='number'){
|
if(typeof host=='number'){
|
||||||
callback=UDPType;
|
callback=UDPType;
|
||||||
|
@ -174,7 +178,7 @@ function serveNet(host,port,UDPType,callback){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!callback){
|
if(!callback){
|
||||||
callback=function(){};
|
callback=emptyCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.server=new Server(
|
ipc.server=new Server(
|
||||||
|
@ -201,7 +205,7 @@ function connect(id,path,callback){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!callback){
|
if(!callback){
|
||||||
callback=function(){};
|
callback=emptyCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!id){
|
if(!id){
|
||||||
|
@ -288,7 +292,7 @@ function connectNet(id,host,port,callback){
|
||||||
callback=false;
|
callback=false;
|
||||||
}
|
}
|
||||||
if(!callback){
|
if(!callback){
|
||||||
callback=function(){};
|
callback=emptyCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ipc.of[id]){
|
if(ipc.of[id]){
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,9 +20,9 @@
|
||||||
</h1>
|
</h1>
|
||||||
<div class='clearfix'>
|
<div class='clearfix'>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">67.65% </span>
|
<span class="strong">67.49% </span>
|
||||||
<span class="quiet">Statements</span>
|
<span class="quiet">Statements</span>
|
||||||
<span class='fraction'>274/405</span>
|
<span class='fraction'>272/403</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">56.37% </span>
|
<span class="strong">56.37% </span>
|
||||||
|
@ -30,14 +30,14 @@
|
||||||
<span class='fraction'>115/204</span>
|
<span class='fraction'>115/204</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">81.4% </span>
|
<span class="strong">80.95% </span>
|
||||||
<span class="quiet">Functions</span>
|
<span class="quiet">Functions</span>
|
||||||
<span class='fraction'>35/43</span>
|
<span class='fraction'>34/42</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">67.65% </span>
|
<span class="strong">67.49% </span>
|
||||||
<span class="quiet">Lines</span>
|
<span class="quiet">Lines</span>
|
||||||
<span class='fraction'>274/405</span>
|
<span class='fraction'>272/403</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -73,15 +73,15 @@
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="file medium" data-value="node-ipc/lib/"><a href="node-ipc/lib/index.html">node-ipc/lib/</a></td>
|
<td class="file medium" data-value="node-ipc/lib/"><a href="node-ipc/lib/index.html">node-ipc/lib/</a></td>
|
||||||
<td data-value="68.15" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 68%;"></div><div class="cover-empty" style="width:32%;"></div></div></td>
|
<td data-value="67.91" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 67%;"></div><div class="cover-empty" style="width:33%;"></div></div></td>
|
||||||
<td data-value="68.15" class="pct medium">68.15%</td>
|
<td data-value="67.91" class="pct medium">67.91%</td>
|
||||||
<td data-value="270" class="abs medium">184/270</td>
|
<td data-value="268" class="abs medium">182/268</td>
|
||||||
<td data-value="54.55" class="pct medium">54.55%</td>
|
<td data-value="54.55" class="pct medium">54.55%</td>
|
||||||
<td data-value="132" class="abs medium">72/132</td>
|
<td data-value="132" class="abs medium">72/132</td>
|
||||||
<td data-value="87.88" class="pct high">87.88%</td>
|
<td data-value="87.5" class="pct high">87.5%</td>
|
||||||
<td data-value="33" class="abs high">29/33</td>
|
<td data-value="32" class="abs high">28/32</td>
|
||||||
<td data-value="68.15" class="pct medium">68.15%</td>
|
<td data-value="67.91" class="pct medium">67.91%</td>
|
||||||
<td data-value="270" class="abs medium">184/270</td>
|
<td data-value="268" class="abs medium">182/268</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
</div><!-- /wrapper -->
|
</div><!-- /wrapper -->
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
Code coverage
|
Code coverage
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 03:37:27 GMT-0800 (PST)
|
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 04:44:52 GMT-0800 (PST)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="prettify.js"></script>
|
<script src="prettify.js"></script>
|
||||||
|
|
|
@ -77,7 +77,7 @@
|
||||||
</div><!-- /wrapper -->
|
</div><!-- /wrapper -->
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
Code coverage
|
Code coverage
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 03:37:27 GMT-0800 (PST)
|
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 04:44:52 GMT-0800 (PST)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="../prettify.js"></script>
|
<script src="../prettify.js"></script>
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
</h1>
|
</h1>
|
||||||
<div class='clearfix'>
|
<div class='clearfix'>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">73.08% </span>
|
<span class="strong">72.82% </span>
|
||||||
<span class="quiet">Statements</span>
|
<span class="quiet">Statements</span>
|
||||||
<span class='fraction'>76/104</span>
|
<span class='fraction'>75/103</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">52.38% </span>
|
<span class="strong">52.38% </span>
|
||||||
|
@ -32,12 +32,12 @@
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">100% </span>
|
<span class="strong">100% </span>
|
||||||
<span class="quiet">Functions</span>
|
<span class="quiet">Functions</span>
|
||||||
<span class='fraction'>11/11</span>
|
<span class='fraction'>10/10</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">73.08% </span>
|
<span class="strong">72.82% </span>
|
||||||
<span class="quiet">Lines</span>
|
<span class="quiet">Lines</span>
|
||||||
<span class='fraction'>76/104</span>
|
<span class='fraction'>75/103</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -278,7 +278,10 @@
|
||||||
233
|
233
|
||||||
234
|
234
|
||||||
235
|
235
|
||||||
236</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1×</span>
|
236
|
||||||
|
237</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
@ -296,6 +299,7 @@
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">7×</span>
|
<span class="cline-any cline-yes">7×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">7×</span>
|
<span class="cline-any cline-yes">7×</span>
|
||||||
|
@ -439,8 +443,6 @@
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">6×</span>
|
<span class="cline-any cline-yes">6×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">6×</span>
|
|
||||||
<span class="cline-any cline-yes">6×</span>
|
<span class="cline-any cline-yes">6×</span>
|
||||||
<span class="cline-any cline-yes">6×</span>
|
<span class="cline-any cline-yes">6×</span>
|
||||||
<span class="cline-any cline-yes">6×</span>
|
<span class="cline-any cline-yes">6×</span>
|
||||||
|
@ -456,7 +458,6 @@
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-yes">6×</span>
|
<span class="cline-any cline-yes">6×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
@ -481,6 +482,7 @@
|
||||||
<span class="cline-any cline-yes">7×</span>
|
<span class="cline-any cline-yes">7×</span>
|
||||||
<span class="cline-any cline-yes">7×</span>
|
<span class="cline-any cline-yes">7×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">7×</span>
|
<span class="cline-any cline-yes">7×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">7×</span>
|
<span class="cline-any cline-yes">7×</span>
|
||||||
|
@ -513,16 +515,18 @@
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">1×</span>
|
<span class="cline-any cline-yes">1×</span>
|
||||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var net = require('net'),
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||||
tls = require('tls'),
|
|
||||||
|
const net = require('net'),
|
||||||
|
tls = require('tls'),
|
||||||
eventParser = require('../lib/eventParser.js'),
|
eventParser = require('../lib/eventParser.js'),
|
||||||
pubsub = require('event-pubsub'),
|
Pubsub = require('event-pubsub'),
|
||||||
Message = require('js-message'),
|
Message = require('js-message'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
Queue = require('js-queue');
|
Queue = require('js-queue');
|
||||||
|
|
||||||
function init(config,log){
|
function init(config,log){
|
||||||
var client={
|
let client={
|
||||||
config : config,
|
config : config,
|
||||||
queue : new Queue,
|
queue : new Queue,
|
||||||
socket : false,
|
socket : false,
|
||||||
|
@ -530,8 +534,9 @@ function init(config,log){
|
||||||
emit : emit,
|
emit : emit,
|
||||||
log : log,
|
log : log,
|
||||||
retriesRemaining:config.maxRetries||<span class="branch-1 cbranch-no" title="branch not covered" >0</span>
|
retriesRemaining:config.maxRetries||<span class="branch-1 cbranch-no" title="branch not covered" >0</span>
|
||||||
}
|
};
|
||||||
new pubsub(client);
|
|
||||||
|
new Pubsub(client);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
@ -539,7 +544,7 @@ function init(config,log){
|
||||||
function emit(type,data){
|
function emit(type,data){
|
||||||
this.log('dispatching event to '.debug, this.id.variable, this.path.variable,' : ', type.data,',', data);
|
this.log('dispatching event to '.debug, this.id.variable, this.path.variable,' : ', type.data,',', data);
|
||||||
|
|
||||||
var message=new Message;
|
let message=new Message;
|
||||||
message.type=type;
|
message.type=type;
|
||||||
message.data=data;
|
message.data=data;
|
||||||
|
|
||||||
|
@ -557,7 +562,7 @@ function emit(type,data){
|
||||||
this.queue.add(
|
this.queue.add(
|
||||||
syncEmit.bind(this,message)
|
syncEmit.bind(this,message)
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|
||||||
function syncEmit(message){
|
function syncEmit(message){
|
||||||
this.log('dispatching event to '.debug, this.id.variable, this.path.variable,' : ', message.data);
|
this.log('dispatching event to '.debug, this.id.variable, this.path.variable,' : ', message.data);
|
||||||
|
@ -566,7 +571,7 @@ function syncEmit(message){
|
||||||
|
|
||||||
function connect(){
|
function connect(){
|
||||||
//init client object for scope persistance especially inside of socket events.
|
//init client object for scope persistance especially inside of socket events.
|
||||||
var client=this;
|
let client=this;
|
||||||
|
|
||||||
client.log('requested connection to '.debug, client.id.variable, client.path.variable);
|
client.log('requested connection to '.debug, client.id.variable, client.path.variable);
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(!this.path){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(!this.path){
|
||||||
|
@ -577,7 +582,7 @@ function connect(){
|
||||||
if(!client.port){
|
if(!client.port){
|
||||||
client.log('Connecting client on Unix Socket :'.debug, client.path.variable);
|
client.log('Connecting client on Unix Socket :'.debug, client.path.variable);
|
||||||
|
|
||||||
var path = client.path;
|
let path = client.path;
|
||||||
|
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (process.platform ==='win32' && <span class="branch-1 cbranch-no" title="branch not covered" >!client.path.startsWith('\\\\.\\pipe\\'))</span>{
|
<span class="missing-if-branch" title="if path not taken" >I</span>if (process.platform ==='win32' && <span class="branch-1 cbranch-no" title="branch not covered" >!client.path.startsWith('\\\\.\\pipe\\'))</span>{
|
||||||
<span class="cstat-no" title="statement not covered" > path = path.replace(/^\//, '');</span>
|
<span class="cstat-no" title="statement not covered" > path = path.replace(/^\//, '');</span>
|
||||||
|
@ -611,7 +616,7 @@ function connect(){
|
||||||
<span class="cstat-no" title="statement not covered" > client.config.tls.trustedConnections=[client.config.tls.trustedConnections];</span>
|
<span class="cstat-no" title="statement not covered" > client.config.tls.trustedConnections=[client.config.tls.trustedConnections];</span>
|
||||||
}
|
}
|
||||||
<span class="cstat-no" title="statement not covered" > client.config.tls.ca=[];</span>
|
<span class="cstat-no" title="statement not covered" > client.config.tls.ca=[];</span>
|
||||||
<span class="cstat-no" title="statement not covered" > for(var i=0; i<client.config.tls.trustedConnections.length; i++){</span>
|
<span class="cstat-no" title="statement not covered" > for(let i=0; i<client.config.tls.trustedConnections.length; i++){</span>
|
||||||
<span class="cstat-no" title="statement not covered" > client.config.tls.ca.push(</span>
|
<span class="cstat-no" title="statement not covered" > client.config.tls.ca.push(</span>
|
||||||
fs.readFileSync(client.config.tls.trustedConnections[i])
|
fs.readFileSync(client.config.tls.trustedConnections[i])
|
||||||
);
|
);
|
||||||
|
@ -640,7 +645,7 @@ function connect(){
|
||||||
|
|
||||||
client.socket.on(
|
client.socket.on(
|
||||||
'connect',
|
'connect',
|
||||||
function(){
|
function connectionMade(){
|
||||||
client.trigger('connect');
|
client.trigger('connect');
|
||||||
client.retriesRemaining=client.config.maxRetries;
|
client.retriesRemaining=client.config.maxRetries;
|
||||||
client.log('retrying reset');
|
client.log('retrying reset');
|
||||||
|
@ -649,7 +654,7 @@ function connect(){
|
||||||
|
|
||||||
client.socket.on(
|
client.socket.on(
|
||||||
'close',
|
'close',
|
||||||
function(){
|
function connectionClosed(){
|
||||||
client.log('connection closed'.notice ,client.id.variable , client.path.variable, client.retriesRemaining+' tries remaining of '+client.config.maxRetries);
|
client.log('connection closed'.notice ,client.id.variable , client.path.variable, client.retriesRemaining+' tries remaining of '+client.config.maxRetries);
|
||||||
|
|
||||||
if(
|
if(
|
||||||
|
@ -660,7 +665,7 @@ function connect(){
|
||||||
client.log(
|
client.log(
|
||||||
client.config.id.variable,
|
client.config.id.variable,
|
||||||
'exceeded connection rety amount of'.warn,
|
'exceeded connection rety amount of'.warn,
|
||||||
" or stopRetrying flag set."
|
' or stopRetrying flag set.'
|
||||||
);
|
);
|
||||||
|
|
||||||
client.socket.destroy();
|
client.socket.destroy();
|
||||||
|
@ -673,22 +678,19 @@ function connect(){
|
||||||
client.isRetrying=true;
|
client.isRetrying=true;
|
||||||
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
(
|
function retryTimeout(){
|
||||||
function(client){
|
client.retriesRemaining--;
|
||||||
return function(){
|
client.isRetrying=false;
|
||||||
client.retriesRemaining--;
|
client.connect();
|
||||||
client.isRetrying=false;
|
setTimeout(
|
||||||
client.connect();
|
function resetRetriesCheck(){
|
||||||
setTimeout(
|
if(!client.isRetrying){
|
||||||
function(){
|
client.retriesRemaining=client.config.maxRetries;
|
||||||
if(!client.isRetrying)
|
}
|
||||||
client.retriesRemaining=client.config.maxRetries;
|
},
|
||||||
},
|
100
|
||||||
100
|
);
|
||||||
)
|
}.bind(null,client),
|
||||||
}
|
|
||||||
}
|
|
||||||
)(client),
|
|
||||||
client.config.retry
|
client.config.retry
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -713,8 +715,9 @@ function connect(){
|
||||||
<span class="cstat-no" title="statement not covered" > return;</span>
|
<span class="cstat-no" title="statement not covered" > return;</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="missing-if-branch" title="else path not taken" >E</span>if(!this.ipcBuffer)
|
<span class="missing-if-branch" title="else path not taken" >E</span>if(!this.ipcBuffer){
|
||||||
this.ipcBuffer='';
|
this.ipcBuffer='';
|
||||||
|
}
|
||||||
|
|
||||||
data=(this.ipcBuffer+=data);
|
data=(this.ipcBuffer+=data);
|
||||||
|
|
||||||
|
@ -725,13 +728,13 @@ function connect(){
|
||||||
|
|
||||||
this.ipcBuffer='';
|
this.ipcBuffer='';
|
||||||
|
|
||||||
var events = eventParser.parse(data);
|
const events = eventParser.parse(data);
|
||||||
var eCount = events.length;
|
const eCount = events.length;
|
||||||
for(var i=0; i<eCount; i++){
|
for(let i=0; i<eCount; i++){
|
||||||
var message=new Message;
|
let message=new Message;
|
||||||
message.load(events[i]);
|
message.load(events[i]);
|
||||||
|
|
||||||
client.log('detected event of type '.debug, message.type.data, message.data);
|
client.log('detected event of type '.debug, message.type.data, message.data);
|
||||||
client.trigger(
|
client.trigger(
|
||||||
message.type,
|
message.type,
|
||||||
message.data
|
message.data
|
||||||
|
@ -754,7 +757,7 @@ module.exports=init;
|
||||||
</div><!-- /wrapper -->
|
</div><!-- /wrapper -->
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
Code coverage
|
Code coverage
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 03:37:27 GMT-0800 (PST)
|
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 04:44:52 GMT-0800 (PST)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="../../prettify.js"></script>
|
<script src="../../prettify.js"></script>
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
</h1>
|
</h1>
|
||||||
<div class='clearfix'>
|
<div class='clearfix'>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">85.71% </span>
|
<span class="strong">84.62% </span>
|
||||||
<span class="quiet">Statements</span>
|
<span class="quiet">Statements</span>
|
||||||
<span class='fraction'>12/14</span>
|
<span class='fraction'>11/13</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">50% </span>
|
<span class="strong">50% </span>
|
||||||
|
@ -35,9 +35,9 @@
|
||||||
<span class='fraction'>2/2</span>
|
<span class='fraction'>2/2</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">85.71% </span>
|
<span class="strong">84.62% </span>
|
||||||
<span class="quiet">Lines</span>
|
<span class="quiet">Lines</span>
|
||||||
<span class='fraction'>12/14</span>
|
<span class='fraction'>11/13</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,7 +70,13 @@
|
||||||
25
|
25
|
||||||
26
|
26
|
||||||
27
|
27
|
||||||
28</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1×</span>
|
28</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1×</span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">1×</span>
|
<span class="cline-any cline-yes">1×</span>
|
||||||
<span class="cline-any cline-yes">9×</span>
|
<span class="cline-any cline-yes">9×</span>
|
||||||
|
@ -91,13 +97,13 @@
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">1×</span>
|
<span class="cline-any cline-yes">1×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||||
<span class="cline-any cline-neutral"> </span>
|
|
||||||
<span class="cline-any cline-neutral"> </span>
|
const parser={
|
||||||
<span class="cline-any cline-neutral"> </span>
|
parse : parseDataEvents,
|
||||||
<span class="cline-any cline-neutral"> </span>
|
format : formatData,
|
||||||
<span class="cline-any cline-yes">1×</span>
|
delimiter : '\f'
|
||||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var Message = require('js-message');
|
};
|
||||||
|
|
||||||
function formatData(message){
|
function formatData(message){
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(!message.data){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(!message.data){
|
||||||
|
@ -109,18 +115,12 @@ function formatData(message){
|
||||||
|
|
||||||
message=message.JSON+parser.delimiter;
|
message=message.JSON+parser.delimiter;
|
||||||
return message;
|
return message;
|
||||||
};
|
|
||||||
|
|
||||||
function parseDataEvents(data){
|
|
||||||
var events=data.split(parser.delimiter);
|
|
||||||
events.pop();
|
|
||||||
return events;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var parser={
|
function parseDataEvents(data){
|
||||||
parse : parseDataEvents,
|
let events=data.split(parser.delimiter);
|
||||||
format : formatData,
|
events.pop();
|
||||||
delimiter : '\f'
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports=parser;
|
module.exports=parser;
|
||||||
|
@ -130,7 +130,7 @@ module.exports=parser;
|
||||||
</div><!-- /wrapper -->
|
</div><!-- /wrapper -->
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
Code coverage
|
Code coverage
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 03:37:27 GMT-0800 (PST)
|
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 04:44:52 GMT-0800 (PST)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="../../prettify.js"></script>
|
<script src="../../prettify.js"></script>
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
</h1>
|
</h1>
|
||||||
<div class='clearfix'>
|
<div class='clearfix'>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">68.15% </span>
|
<span class="strong">67.91% </span>
|
||||||
<span class="quiet">Statements</span>
|
<span class="quiet">Statements</span>
|
||||||
<span class='fraction'>184/270</span>
|
<span class='fraction'>182/268</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">54.55% </span>
|
<span class="strong">54.55% </span>
|
||||||
|
@ -30,14 +30,14 @@
|
||||||
<span class='fraction'>72/132</span>
|
<span class='fraction'>72/132</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">87.88% </span>
|
<span class="strong">87.5% </span>
|
||||||
<span class="quiet">Functions</span>
|
<span class="quiet">Functions</span>
|
||||||
<span class='fraction'>29/33</span>
|
<span class='fraction'>28/32</span>
|
||||||
</div>
|
</div>
|
||||||
<div class='fl pad1y space-right2'>
|
<div class='fl pad1y space-right2'>
|
||||||
<span class="strong">68.15% </span>
|
<span class="strong">67.91% </span>
|
||||||
<span class="quiet">Lines</span>
|
<span class="quiet">Lines</span>
|
||||||
<span class='fraction'>184/270</span>
|
<span class='fraction'>182/268</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,28 +60,28 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody><tr>
|
<tbody><tr>
|
||||||
<td class="file medium" data-value="client.js"><a href="client.js.html">client.js</a></td>
|
<td class="file medium" data-value="client.js"><a href="client.js.html">client.js</a></td>
|
||||||
<td data-value="73.08" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 73%;"></div><div class="cover-empty" style="width:27%;"></div></div></td>
|
<td data-value="72.82" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 72%;"></div><div class="cover-empty" style="width:28%;"></div></div></td>
|
||||||
<td data-value="73.08" class="pct medium">73.08%</td>
|
<td data-value="72.82" class="pct medium">72.82%</td>
|
||||||
<td data-value="104" class="abs medium">76/104</td>
|
<td data-value="103" class="abs medium">75/103</td>
|
||||||
<td data-value="52.38" class="pct medium">52.38%</td>
|
<td data-value="52.38" class="pct medium">52.38%</td>
|
||||||
<td data-value="42" class="abs medium">22/42</td>
|
<td data-value="42" class="abs medium">22/42</td>
|
||||||
<td data-value="100" class="pct high">100%</td>
|
<td data-value="100" class="pct high">100%</td>
|
||||||
<td data-value="11" class="abs high">11/11</td>
|
<td data-value="10" class="abs high">10/10</td>
|
||||||
<td data-value="73.08" class="pct medium">73.08%</td>
|
<td data-value="72.82" class="pct medium">72.82%</td>
|
||||||
<td data-value="104" class="abs medium">76/104</td>
|
<td data-value="103" class="abs medium">75/103</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="file high" data-value="eventParser.js"><a href="eventParser.js.html">eventParser.js</a></td>
|
<td class="file high" data-value="eventParser.js"><a href="eventParser.js.html">eventParser.js</a></td>
|
||||||
<td data-value="85.71" class="pic high"><div class="chart"><div class="cover-fill" style="width: 85%;"></div><div class="cover-empty" style="width:15%;"></div></div></td>
|
<td data-value="84.62" class="pic high"><div class="chart"><div class="cover-fill" style="width: 84%;"></div><div class="cover-empty" style="width:16%;"></div></div></td>
|
||||||
<td data-value="85.71" class="pct high">85.71%</td>
|
<td data-value="84.62" class="pct high">84.62%</td>
|
||||||
<td data-value="14" class="abs high">12/14</td>
|
<td data-value="13" class="abs high">11/13</td>
|
||||||
<td data-value="50" class="pct medium">50%</td>
|
<td data-value="50" class="pct medium">50%</td>
|
||||||
<td data-value="4" class="abs medium">2/4</td>
|
<td data-value="4" class="abs medium">2/4</td>
|
||||||
<td data-value="100" class="pct high">100%</td>
|
<td data-value="100" class="pct high">100%</td>
|
||||||
<td data-value="2" class="abs high">2/2</td>
|
<td data-value="2" class="abs high">2/2</td>
|
||||||
<td data-value="85.71" class="pct high">85.71%</td>
|
<td data-value="84.62" class="pct high">84.62%</td>
|
||||||
<td data-value="14" class="abs high">12/14</td>
|
<td data-value="13" class="abs high">11/13</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
</div><!-- /wrapper -->
|
</div><!-- /wrapper -->
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
Code coverage
|
Code coverage
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 03:37:27 GMT-0800 (PST)
|
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 04:44:52 GMT-0800 (PST)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="../../prettify.js"></script>
|
<script src="../../prettify.js"></script>
|
||||||
|
|
|
@ -410,7 +410,15 @@
|
||||||
365
|
365
|
||||||
366
|
366
|
||||||
367
|
367
|
||||||
368</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1×</span>
|
368
|
||||||
|
369
|
||||||
|
370
|
||||||
|
371
|
||||||
|
372
|
||||||
|
373
|
||||||
|
374</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
@ -597,6 +605,7 @@
|
||||||
<span class="cline-any cline-yes">4×</span>
|
<span class="cline-any cline-yes">4×</span>
|
||||||
<span class="cline-any cline-yes">2×</span>
|
<span class="cline-any cline-yes">2×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">4×</span>
|
<span class="cline-any cline-yes">4×</span>
|
||||||
<span class="cline-any cline-yes">4×</span>
|
<span class="cline-any cline-yes">4×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
@ -634,6 +643,7 @@
|
||||||
<span class="cline-any cline-yes">2×</span>
|
<span class="cline-any cline-yes">2×</span>
|
||||||
<span class="cline-any cline-yes">2×</span>
|
<span class="cline-any cline-yes">2×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">2×</span>
|
<span class="cline-any cline-yes">2×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">2×</span>
|
<span class="cline-any cline-yes">2×</span>
|
||||||
|
@ -668,6 +678,8 @@
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">2×</span>
|
<span class="cline-any cline-yes">2×</span>
|
||||||
<span class="cline-any cline-no"> </span>
|
<span class="cline-any cline-no"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">2×</span>
|
<span class="cline-any cline-yes">2×</span>
|
||||||
<span class="cline-any cline-yes">2×</span>
|
<span class="cline-any cline-yes">2×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
@ -777,18 +789,20 @@
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">1×</span>
|
<span class="cline-any cline-yes">1×</span>
|
||||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var net = require('net'),
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||||
tls = require('tls'),
|
|
||||||
fs = require('fs'),
|
const net = require('net'),
|
||||||
dgram = require('dgram'),
|
tls = require('tls'),
|
||||||
|
fs = require('fs'),
|
||||||
|
dgram = require('dgram'),
|
||||||
eventParser = require('../lib/eventParser.js'),
|
eventParser = require('../lib/eventParser.js'),
|
||||||
pubsub = require('event-pubsub'),
|
Pubsub = require('event-pubsub'),
|
||||||
Message = require('js-message');
|
Message = require('js-message');
|
||||||
|
|
||||||
function emit(socket, type, data){
|
function emit(socket, type, data){
|
||||||
this.log('dispatching event to socket'.debug, ' : ', type.data, data);
|
this.log('dispatching event to socket'.debug, ' : ', type.data, data);
|
||||||
|
|
||||||
var message=new Message;
|
let message=new Message;
|
||||||
message.type=type;
|
message.type=type;
|
||||||
message.data=data;
|
message.data=data;
|
||||||
|
|
||||||
|
@ -811,14 +825,14 @@ function emit(socket, type, data){
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
<span class="cstat-no" title="statement not covered" > socket.write(message);</span>
|
<span class="cstat-no" title="statement not covered" > socket.write(message);</span>
|
||||||
};
|
}
|
||||||
|
|
||||||
<span class="fstat-no" title="function not covered" >function broadcast(type,data){</span>
|
<span class="fstat-no" title="function not covered" >function broadcast(type,data){</span>
|
||||||
<span class="cstat-no" title="statement not covered" > this.log('broadcasting event to all known sockets listening to '.debug, this.path.variable,' : ', ((this.port)?this.port:''), type, data);</span>
|
<span class="cstat-no" title="statement not covered" > this.log('broadcasting event to all known sockets listening to '.debug, this.path.variable,' : ', ((this.port)?this.port:''), type, data);</span>
|
||||||
<span class="cstat-no" title="statement not covered" > var message=new Message;</span>
|
<span class="cstat-no" title="statement not covered" > let message=new Message;</span>
|
||||||
<span class="cstat-no" title="statement not covered" > message.type=type;</span>
|
<span class="cstat-no" title="statement not covered" > message.type=type;</span>
|
||||||
<span class="cstat-no" title="statement not covered" > message.data=data;</span>
|
<span class="cstat-no" title="statement not covered" > message.data=data;</span>
|
||||||
|
|
||||||
|
@ -829,18 +843,18 @@ function emit(socket, type, data){
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="cstat-no" title="statement not covered" > if(this.udp4 || this.udp6){</span>
|
<span class="cstat-no" title="statement not covered" > if(this.udp4 || this.udp6){</span>
|
||||||
<span class="cstat-no" title="statement not covered" > for(var i=1, count=this.sockets.length; i<count; i++){</span>
|
<span class="cstat-no" title="statement not covered" > for(let i=1, count=this.sockets.length; i<count; i++){</span>
|
||||||
<span class="cstat-no" title="statement not covered" > this.server.write(message,this.sockets[i]);</span>
|
<span class="cstat-no" title="statement not covered" > this.server.write(message,this.sockets[i]);</span>
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
<span class="cstat-no" title="statement not covered" > for(var i=0, count=this.sockets.length; i<count; i++){</span>
|
<span class="cstat-no" title="statement not covered" > for(let i=0, count=this.sockets.length; i<count; i++){</span>
|
||||||
<span class="cstat-no" title="statement not covered" > this.sockets[i].write(message);</span>
|
<span class="cstat-no" title="statement not covered" > this.sockets[i].write(message);</span>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function init(path,config,log,port){
|
function init(path,config,log,port){
|
||||||
var server={
|
let server={
|
||||||
config : config,
|
config : config,
|
||||||
path : path,
|
path : path,
|
||||||
port : port,
|
port : port,
|
||||||
|
@ -898,7 +912,7 @@ function init(path,config,log,port){
|
||||||
<span class="cstat-no" title="statement not covered" > server.config.tls.trustedConnections=[server.config.tls.trustedConnections];</span>
|
<span class="cstat-no" title="statement not covered" > server.config.tls.trustedConnections=[server.config.tls.trustedConnections];</span>
|
||||||
}
|
}
|
||||||
<span class="cstat-no" title="statement not covered" > server.config.tls.ca=[];</span>
|
<span class="cstat-no" title="statement not covered" > server.config.tls.ca=[];</span>
|
||||||
<span class="cstat-no" title="statement not covered" > for(var i=0; i<server.config.tls.trustedConnections.length; i++){</span>
|
<span class="cstat-no" title="statement not covered" > for(let i=0; i<server.config.tls.trustedConnections.length; i++){</span>
|
||||||
<span class="cstat-no" title="statement not covered" > server.config.tls.ca.push(</span>
|
<span class="cstat-no" title="statement not covered" > server.config.tls.ca.push(</span>
|
||||||
fs.readFileSync(server.config.tls.trustedConnections[i])
|
fs.readFileSync(server.config.tls.trustedConnections[i])
|
||||||
);
|
);
|
||||||
|
@ -911,7 +925,7 @@ function init(path,config,log,port){
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
function UDPWrite(message,socket){
|
function UDPWrite(message,socket){
|
||||||
var data=new Buffer(message, server.config.encoding);
|
let data=new Buffer(message, server.config.encoding);
|
||||||
server.server.send(
|
server.server.send(
|
||||||
data,
|
data,
|
||||||
0,
|
0,
|
||||||
|
@ -939,7 +953,7 @@ function init(path,config,log,port){
|
||||||
server.server.on(
|
server.server.on(
|
||||||
'listening',
|
'listening',
|
||||||
function () {
|
function () {
|
||||||
serverCreated(server.server)
|
serverCreated(server.server);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -952,7 +966,7 @@ function init(path,config,log,port){
|
||||||
<span class="cstat-no" title="statement not covered" > server.trigger(</span>
|
<span class="cstat-no" title="statement not covered" > server.trigger(</span>
|
||||||
'error',
|
'error',
|
||||||
err
|
err
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -961,8 +975,9 @@ function init(path,config,log,port){
|
||||||
function serverCreated(socket) {
|
function serverCreated(socket) {
|
||||||
server.sockets.push(socket);
|
server.sockets.push(socket);
|
||||||
|
|
||||||
if(socket.setEncoding)
|
if(socket.setEncoding){
|
||||||
socket.setEncoding(server.config.encoding);
|
socket.setEncoding(server.config.encoding);
|
||||||
|
}
|
||||||
|
|
||||||
server.log('## socket connection to server detected ##'.rainbow);
|
server.log('## socket connection to server detected ##'.rainbow);
|
||||||
socket.on(
|
socket.on(
|
||||||
|
@ -987,7 +1002,7 @@ function init(path,config,log,port){
|
||||||
socket.on(
|
socket.on(
|
||||||
'data',
|
'data',
|
||||||
function(data,UDPSocket){
|
function(data,UDPSocket){
|
||||||
var sock=((server.udp4 || server.udp6)? UDPSocket : <span class="branch-1 cbranch-no" title="branch not covered" >socket)</span>;
|
let sock=((server.udp4 || server.udp6)? UDPSocket : <span class="branch-1 cbranch-no" title="branch not covered" >socket)</span>;
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(server.config.rawBuffer){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(server.config.rawBuffer){
|
||||||
<span class="cstat-no" title="statement not covered" > data=new Buffer(data,this.encoding);</span>
|
<span class="cstat-no" title="statement not covered" > data=new Buffer(data,this.encoding);</span>
|
||||||
<span class="cstat-no" title="statement not covered" > server.trigger(</span>
|
<span class="cstat-no" title="statement not covered" > server.trigger(</span>
|
||||||
|
@ -998,8 +1013,9 @@ function init(path,config,log,port){
|
||||||
<span class="cstat-no" title="statement not covered" > return;</span>
|
<span class="cstat-no" title="statement not covered" > return;</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="missing-if-branch" title="else path not taken" >E</span>if(!this.ipcBuffer)
|
<span class="missing-if-branch" title="else path not taken" >E</span>if(!this.ipcBuffer){
|
||||||
this.ipcBuffer='';
|
this.ipcBuffer='';
|
||||||
|
}
|
||||||
|
|
||||||
data=(this.ipcBuffer+=data);
|
data=(this.ipcBuffer+=data);
|
||||||
|
|
||||||
|
@ -1013,7 +1029,7 @@ function init(path,config,log,port){
|
||||||
data=eventParser.parse(data);
|
data=eventParser.parse(data);
|
||||||
|
|
||||||
while(data.length>0){
|
while(data.length>0){
|
||||||
var message=new Message;
|
let message=new Message;
|
||||||
message.load(data.shift());
|
message.load(data.shift());
|
||||||
|
|
||||||
server.log('received event of : '.debug,message.type.data,message.data);
|
server.log('received event of : '.debug,message.type.data,message.data);
|
||||||
|
@ -1033,10 +1049,12 @@ function init(path,config,log,port){
|
||||||
socket.on(
|
socket.on(
|
||||||
'message',
|
'message',
|
||||||
function(msg,rinfo) {
|
function(msg,rinfo) {
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (!rinfo)
|
<span class="missing-if-branch" title="if path not taken" >I</span>if (!rinfo){
|
||||||
<span class="cstat-no" title="statement not covered" > return;</span>
|
<span class="cstat-no" title="statement not covered" > return;</span>
|
||||||
|
}
|
||||||
|
|
||||||
server.log('Received UDP message from '.debug, rinfo.address.variable, rinfo.port);
|
server.log('Received UDP message from '.debug, rinfo.address.variable, rinfo.port);
|
||||||
var data;
|
let data;
|
||||||
|
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(server.config.rawSocket){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(server.config.rawSocket){
|
||||||
<span class="cstat-no" title="statement not covered" > data=new Buffer(msg,this.encoding);</span>
|
<span class="cstat-no" title="statement not covered" > data=new Buffer(msg,this.encoding);</span>
|
||||||
|
@ -1058,16 +1076,16 @@ function init(path,config,log,port){
|
||||||
}
|
}
|
||||||
|
|
||||||
function started(socket){
|
function started(socket){
|
||||||
server.onStart(socket)
|
server.onStart(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!port){
|
if(!port){
|
||||||
server.log('starting server as'.debug, 'Unix || Windows Socket'.variable);
|
server.log('starting server as'.debug, 'Unix || Windows Socket'.variable);
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if (process.platform ==='win32'){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if (process.platform ==='win32'){
|
||||||
<span class="cstat-no" title="statement not covered" > server.path = server.path.replace(/^\//, '');</span>
|
<span class="cstat-no" title="statement not covered" > server.path = server.path.replace(/^\//, '');</span>
|
||||||
<span class="cstat-no" title="statement not covered" > server.path = server.path.replace(/\//g, '-');</span>
|
<span class="cstat-no" title="statement not covered" > server.path = server.path.replace(/\//g, '-');</span>
|
||||||
<span class="cstat-no" title="statement not covered" > server.path= '\\\\.\\pipe\\'+server.path;</span>
|
<span class="cstat-no" title="statement not covered" > server.path= '\\\\.\\pipe\\'+server.path;</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
server.server.listen(
|
server.server.listen(
|
||||||
server.path,
|
server.path,
|
||||||
|
@ -1099,21 +1117,21 @@ function init(path,config,log,port){
|
||||||
port : server.port
|
port : server.port
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
)(this)
|
)(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
new pubsub(server);
|
new Pubsub(server);
|
||||||
|
|
||||||
server.on(
|
server.on(
|
||||||
'close',
|
'close',
|
||||||
function(){
|
function(){
|
||||||
for(var i=0, count=server.sockets.length; i<count; i++){
|
for(let i=0, count=server.sockets.length; i<count; i++){
|
||||||
var socket=server.sockets[i];
|
let socket=server.sockets[i];
|
||||||
var destroyedSocketId=false;
|
let destroyedSocketId=false;
|
||||||
|
|
||||||
<span class="missing-if-branch" title="else path not taken" >E</span>if(socket){
|
<span class="missing-if-branch" title="else path not taken" >E</span>if(socket){
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(socket.readable){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(socket.readable){
|
||||||
|
@ -1122,7 +1140,7 @@ function init(path,config,log,port){
|
||||||
}
|
}
|
||||||
|
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(socket.id){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(socket.id){
|
||||||
<span class="cstat-no" title="statement not covered" > destroyedSocketId=socket.id;</span>
|
<span class="cstat-no" title="statement not covered" > destroyedSocketId=socket.id;</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
server.log('socket disconnected'.notice,' '+destroyedSocketId.variable);
|
server.log('socket disconnected'.notice,' '+destroyedSocketId.variable);
|
||||||
|
@ -1150,7 +1168,7 @@ module.exports=init;
|
||||||
</div><!-- /wrapper -->
|
</div><!-- /wrapper -->
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
Code coverage
|
Code coverage
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 03:37:27 GMT-0800 (PST)
|
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 04:44:52 GMT-0800 (PST)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="../../prettify.js"></script>
|
<script src="../../prettify.js"></script>
|
||||||
|
|
|
@ -359,8 +359,10 @@
|
||||||
314
|
314
|
||||||
315
|
315
|
||||||
316
|
316
|
||||||
317</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1×</span>
|
317
|
||||||
|
318</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
<span class="cline-any cline-yes">1×</span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
|
@ -675,14 +677,15 @@
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-neutral"> </span>
|
<span class="cline-any cline-neutral"> </span>
|
||||||
<span class="cline-any cline-yes">1×</span>
|
<span class="cline-any cline-yes">1×</span>
|
||||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">var os = require('os'),
|
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||||
dns = require('dns'),
|
|
||||||
util = require('util'),
|
const os = require('os'),
|
||||||
colors = require('colors'),
|
dns = require('dns'),
|
||||||
pubsub = require('event-pubsub'),
|
util = require('util'),
|
||||||
|
colors = require('colors'),
|
||||||
eventParser = require('./lib/eventParser.js'),
|
eventParser = require('./lib/eventParser.js'),
|
||||||
Client = require('./lib/client.js'),
|
Client = require('./lib/client.js'),
|
||||||
Server = require('./lib/socketServer.js');
|
Server = require('./lib/socketServer.js');
|
||||||
|
|
||||||
colors.setTheme(
|
colors.setTheme(
|
||||||
{
|
{
|
||||||
|
@ -696,11 +699,11 @@ colors.setTheme(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var IPType=os.networkInterfaces()[
|
const IPType=os.networkInterfaces()[
|
||||||
Object.keys(os.networkInterfaces())[0]
|
Object.keys(os.networkInterfaces())[0]
|
||||||
][0].family
|
][0].family;
|
||||||
|
|
||||||
var defaults={
|
let defaults={
|
||||||
appspace : 'app.',
|
appspace : 'app.',
|
||||||
socketRoot : '/tmp/',
|
socketRoot : '/tmp/',
|
||||||
networkHost : (IPType=='IPv6')? <span class="branch-0 cbranch-no" title="branch not covered" >'::1' </span>: '127.0.0.1',
|
networkHost : (IPType=='IPv6')? <span class="branch-0 cbranch-no" title="branch not covered" >'::1' </span>: '127.0.0.1',
|
||||||
|
@ -716,9 +719,9 @@ var defaults={
|
||||||
stopRetrying : false,
|
stopRetrying : false,
|
||||||
IPType : IPType,
|
IPType : IPType,
|
||||||
tls : false
|
tls : false
|
||||||
}
|
};
|
||||||
|
|
||||||
var ipc = {
|
let ipc = {
|
||||||
config : defaults,
|
config : defaults,
|
||||||
connectTo : connect,
|
connectTo : connect,
|
||||||
connectToNet: connectNet,
|
connectToNet: connectNet,
|
||||||
|
@ -728,16 +731,16 @@ var ipc = {
|
||||||
of : {},
|
of : {},
|
||||||
server : false,
|
server : false,
|
||||||
log : log
|
log : log
|
||||||
}
|
};
|
||||||
|
|
||||||
function log(){
|
function log(){
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(ipc.config.silent){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(ipc.config.silent){
|
||||||
<span class="cstat-no" title="statement not covered" > return;</span>
|
<span class="cstat-no" title="statement not covered" > return;</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
var args=Array.prototype.slice.call(arguments);
|
let args=Array.prototype.slice.call(arguments);
|
||||||
|
|
||||||
for(var i=0, count=args.length; i<count; i++){
|
for(let i=0, count=args.length; i<count; i++){
|
||||||
if(typeof args[i] != 'object'){
|
if(typeof args[i] != 'object'){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -765,7 +768,7 @@ function disconnect(id){
|
||||||
}
|
}
|
||||||
|
|
||||||
delete ipc.of[id];
|
delete ipc.of[id];
|
||||||
};
|
}
|
||||||
|
|
||||||
function serve(path,callback){
|
function serve(path,callback){
|
||||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(typeof path=='function'){
|
<span class="missing-if-branch" title="if path not taken" >I</span>if(typeof path=='function'){
|
||||||
|
@ -910,9 +913,9 @@ function connect(id,path,callback){
|
||||||
<span class="cstat-no" title="statement not covered" > ipc.of[id].socket.destroy();</span>
|
<span class="cstat-no" title="statement not covered" > ipc.of[id].socket.destroy();</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.of[id] = new Client(ipc.config,ipc.log);
|
ipc.of[id] = new Client(ipc.config,ipc.log);
|
||||||
ipc.of[id].id = id;
|
ipc.of[id].id = id;
|
||||||
ipc.of[id].path = path;
|
ipc.of[id].path = path;
|
||||||
|
|
||||||
ipc.of[id].connect();
|
ipc.of[id].connect();
|
||||||
|
|
||||||
|
@ -980,10 +983,10 @@ function connectNet(id,host,port,callback){
|
||||||
<span class="cstat-no" title="statement not covered" > ipc.of[id].socket.destroy();</span>
|
<span class="cstat-no" title="statement not covered" > ipc.of[id].socket.destroy();</span>
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.of[id] = new Client(ipc.config,ipc.log);
|
ipc.of[id] = new Client(ipc.config,ipc.log);
|
||||||
ipc.of[id].id = id;
|
ipc.of[id].id = id;
|
||||||
ipc.of[id].path = host;
|
ipc.of[id].path = host;
|
||||||
ipc.of[id].port = port;
|
ipc.of[id].port = port;
|
||||||
|
|
||||||
ipc.of[id].connect();
|
ipc.of[id].connect();
|
||||||
|
|
||||||
|
@ -997,7 +1000,7 @@ module.exports=ipc;
|
||||||
</div><!-- /wrapper -->
|
</div><!-- /wrapper -->
|
||||||
<div class='footer quiet pad2 space-top1 center small'>
|
<div class='footer quiet pad2 space-top1 center small'>
|
||||||
Code coverage
|
Code coverage
|
||||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 03:37:27 GMT-0800 (PST)
|
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Sun Jan 10 2016 04:44:52 GMT-0800 (PST)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script src="../prettify.js"></script>
|
<script src="../prettify.js"></script>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
var addSorting = (function () {
|
var addSorting = (function () {
|
||||||
'use strict';
|
"use strict";
|
||||||
var cols,
|
var cols,
|
||||||
currentSort = {
|
currentSort = {
|
||||||
index: 0,
|
index: 0,
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@ describe('TCP Socket verification of client',
|
||||||
function TCPClientSpec(){
|
function TCPClientSpec(){
|
||||||
it(
|
it(
|
||||||
'Verify retry attempts by TCP client to connect to the server as per the value set in "maxRetries" parameter.',
|
'Verify retry attempts by TCP client to connect to the server as per the value set in "maxRetries" parameter.',
|
||||||
function(done){
|
function testIt(done){
|
||||||
ipc.config.id ='testClient';
|
ipc.config.id ='testClient';
|
||||||
ipc.config.retry = 600;
|
ipc.config.retry = 600;
|
||||||
ipc.config.maxRetries = 3;
|
ipc.config.maxRetries = 3;
|
||||||
|
@ -97,7 +97,7 @@ describe('TCP Socket verification of client',
|
||||||
function connected(){
|
function connected(){
|
||||||
ipc.of.tcpServer.on(
|
ipc.of.tcpServer.on(
|
||||||
'message',
|
'message',
|
||||||
function(data,socket){
|
function gotMessage(data){
|
||||||
expect(data.id).toBe('tcpServer');
|
expect(data.id).toBe('tcpServer');
|
||||||
expect(data.message).toBe('I am TCP server!');
|
expect(data.message).toBe('I am TCP server!');
|
||||||
testDone();
|
testDone();
|
||||||
|
|
|
@ -61,7 +61,7 @@ describe(
|
||||||
|
|
||||||
it(
|
it(
|
||||||
'Verify UDP server of type udp6 connects to UDP server named "udp6Server" and receives message.',
|
'Verify UDP server of type udp6 connects to UDP server named "udp6Server" and receives message.',
|
||||||
function(done){
|
function testIt(done){
|
||||||
ipc.config.networkPort=8099;
|
ipc.config.networkPort=8099;
|
||||||
ipc.config.id ='testClient';
|
ipc.config.id ='testClient';
|
||||||
ipc.config.retry = 600;
|
ipc.config.retry = 600;
|
||||||
|
@ -75,7 +75,8 @@ describe(
|
||||||
function serverStarted(){
|
function serverStarted(){
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'message',
|
'message',
|
||||||
function(data,socket){
|
function gotMessage(data,socket){
|
||||||
|
expect(socket).toBeDefined();
|
||||||
expect(data.id).toBe('udp6Server');
|
expect(data.id).toBe('udp6Server');
|
||||||
expect(data.message).toBe('I am UDP6 server!');
|
expect(data.message).toBe('I am UDP6 server!');
|
||||||
testDone();
|
testDone();
|
||||||
|
|
|
@ -98,7 +98,7 @@ describe('Test Cases for Unix client: ',
|
||||||
function connected(){
|
function connected(){
|
||||||
ipc.of.unixServer.on(
|
ipc.of.unixServer.on(
|
||||||
'message',
|
'message',
|
||||||
function(data){
|
function gotMessage(data){
|
||||||
expect(data.id).toBe('unixServer');
|
expect(data.id).toBe('unixServer');
|
||||||
expect(data.message).toBe('I am unix server!');
|
expect(data.message).toBe('I am unix server!');
|
||||||
testDone();
|
testDone();
|
||||||
|
|
|
@ -23,7 +23,7 @@ describe(
|
||||||
function serverStarted(){
|
function serverStarted(){
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'connect',
|
'connect',
|
||||||
function(data,socket){
|
function connected(){
|
||||||
clientCounter++;
|
clientCounter++;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -31,7 +31,7 @@ describe(
|
||||||
);
|
);
|
||||||
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
function(){
|
function clientCountDelay(){
|
||||||
expect(clientCounter).toBe(ipc.config.maxConnections);
|
expect(clientCounter).toBe(ipc.config.maxConnections);
|
||||||
ipc.server.stop();
|
ipc.server.stop();
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const ipc = require('../../../../node-ipc');
|
|
||||||
const cmd=require('node-cmd');
|
const cmd=require('node-cmd');
|
||||||
|
|
||||||
cmd.run(`node ${__dirname}/unixServer.js`);
|
cmd.run(`node ${__dirname}/unixServer.js`);
|
||||||
|
|
Loading…
Reference in a new issue