diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 878256a..2e7c99c 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -20,7 +20,6 @@ jobs: - macos-latest - windows-latest node_version: - - 12.x - 14.x - 16.x steps: diff --git a/README.md b/README.md index e2d794e..f16d111 100644 --- a/README.md +++ b/README.md @@ -11,18 +11,13 @@ A great solution for complex multiprocess **Neural Networking** in Node.JS npm info : [See npm trends and stats for node-ipc](http://npm-stat.com/charts.html?package=node-ipc&author=&from=&to=) [![NPM](https://nodei.co/npm/node-ipc.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/node-ipc/) [![Package Quality](http://npm.packagequality.com/badge/node-ipc.png)](http://packagequality.com/#?package=node-ipc) -![node-ipc npm version](https://img.shields.io/npm/v/node-ipc.svg) ![supported node version for node-ipc](https://img.shields.io/node/v/node-ipc.svg) ![total npm downloads for node-ipc](https://img.shields.io/npm/dt/node-ipc.svg) ![monthly npm downloads for node-ipc](https://img.shields.io/npm/dm/node-ipc.svg) ![npm licence for node-ipc](https://img.shields.io/npm/l/node-ipc.svg) - -[![RIAEvangelist](https://avatars3.githubusercontent.com/u/369041?v=3&s=100)](https://github.com/RIAEvangelist) +![node-ipc npm version](https://img.shields.io/npm/v/node-ipc.svg) ![supported node version for node-ipc](https://img.shields.io/node/v/node-ipc.svg) ![total npm downloads for node-ipc](https://img.shields.io/npm/dt/node-ipc.svg) ![monthly npm downloads for node-ipc](https://img.shields.io/npm/dm/node-ipc.svg) ![npm licence for node-ipc](https://img.shields.io/npm/l/node-ipc.svg) GitHub info : ![node-ipc GitHub Release](https://img.shields.io/github/release/RIAEvangelist/node-ipc.svg) ![GitHub license node-ipc license](https://img.shields.io/github/license/RIAEvangelist/node-ipc.svg) ![open issues for node-ipc on GitHub](https://img.shields.io/github/issues/RIAEvangelist/node-ipc.svg) -Codacy info : -[![Codacy Badge](https://api.codacy.com/project/badge/grade/8e0294dff55f4ac1985c07b16f39d0a9)](https://www.codacy.com/app/RIAEvangelist/node-ipc) [![Codacy Badge](https://api.codacy.com/project/badge/coverage/8e0294dff55f4ac1985c07b16f39d0a9)](https://www.codacy.com/app/RIAEvangelist/node-ipc) - -Build Info : -Mac & Linux : [![Build Status](https://travis-ci.org/RIAEvangelist/node-ipc.svg?branch=master)](https://travis-ci.org/RIAEvangelist/node-ipc) Windows : [![node-ipc windows build status](https://ci.appveyor.com/api/projects/status/github/riaevangelist/node-ipc?branch=master&svg=true)](https://ci.appveyor.com/project/RIAEvangelist/node-ipc/history) +Code Coverage Info : +![lcov node-ipc](/blob/main/coverage/lcov.svg) Package details websites : * [GitHub.io site](http://riaevangelist.github.io/node-ipc/ "node-ipc documentation"). A prettier version of this site. @@ -487,14 +482,14 @@ Sometimes you might need explicit and independent instances of node-ipc. Just fo ```javascript - const RawIPC=require('node-ipc').IPC; + const RawIPC=from 'node-ipc').IPC; const ipc=new RawIPC; const someOtherExplicitIPC=new RawIPC; //OR - const ipc=require('node-ipc'); + const ipc=from 'node-ipc'); const someOtherExplicitIPC=new ipc.IPC; @@ -522,7 +517,7 @@ The server is the process keeping a socket for IPC open. Multiple sockets can co ```javascript - var ipc=require('node-ipc'); + var ipc=from 'node-ipc'); ipc.config.id = 'world'; ipc.config.retry= 1500; @@ -559,7 +554,7 @@ The client connects to the servers socket for Inter Process Communication. The s ```javascript - var ipc=require('node-ipc'); + var ipc=from 'node-ipc'); ipc.config.id = 'hello'; ipc.config.retry= 1500; @@ -605,7 +600,7 @@ This is the most basic example which will work for both local and remote UDP Soc ```javascript - var ipc=require('../../../node-ipc'); + var ipc=from '../../../node-ipc'); ipc.config.id = 'world'; ipc.config.retry= 1500; @@ -800,10 +795,10 @@ Writing explicit buffers, int types, doubles, floats etc. as well as big endian ```javascript - const fs = require('fs'); - const ipc=require('../../../node-ipc'); - const cpuCount = require('os').cpus().length; - const cluster = require('cluster'); + const fs = from 'fs'); + const ipc=from '../../../node-ipc'); + const cpuCount = from 'os').cpus().length; + const cluster = from 'cluster'); const socketPath = '/tmp/ipc.sock'; ipc.config.unlink = false; @@ -839,8 +834,8 @@ Writing explicit buffers, int types, doubles, floats etc. as well as big endian ```javascript - const fs = require('fs'); - const ipc = require('../../node-ipc'); + const fs = from 'fs'); + const ipc = from '../../node-ipc'); const socketPath = '/tmp/ipc.sock'; diff --git a/spec/coverage/lcov-report/base.css b/coverage/base.css similarity index 89% rename from spec/coverage/lcov-report/base.css rename to coverage/base.css index 0c0571d..f418035 100644 --- a/spec/coverage/lcov-report/base.css +++ b/coverage/base.css @@ -7,7 +7,7 @@ body { font-size: 14px; color:#333; } -.small { font-size: 12px;; } +.small { font-size: 12px; } *, *:after, *:before { -webkit-box-sizing:border-box; -moz-box-sizing:border-box; @@ -152,9 +152,15 @@ table.coverage td span.cline-any { background-position: 0 -10px; } .status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } /* dark red */ .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } .low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} /* medium red */ .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } /* light red */ @@ -166,19 +172,25 @@ table.coverage td span.cline-any { /* dark green */ .status-line.high, .high .cover-fill { background:rgb(77,146,33) } .high .chart { border:1px solid rgb(77,146,33) } - - -.medium .chart { border:1px solid #666; } -.medium .cover-fill { background: #666; } - -.cbranch-no { background: yellow !important; color: #111; } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } .cstat-skip { background: #ddd; color: #111; } .fstat-skip { background: #ddd; color: #111 !important; } .cbranch-skip { background: #ddd !important; color: #111; } span.cline-neutral { background: #eaeaea; } -.medium { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} .cover-fill, .cover-empty { display:inline-block; diff --git a/coverage/block-navigation.js b/coverage/block-navigation.js new file mode 100644 index 0000000..c7ff5a5 --- /dev/null +++ b/coverage/block-navigation.js @@ -0,0 +1,79 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selecter that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/coverage/favicon.png b/coverage/favicon.png new file mode 100644 index 0000000..6691817 Binary files /dev/null and b/coverage/favicon.png differ diff --git a/coverage/index.html b/coverage/index.html new file mode 100644 index 0000000..e562078 --- /dev/null +++ b/coverage/index.html @@ -0,0 +1,171 @@ + + + + +
++ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
node-ipc | +
+
+ |
+ 100% | +24/24 | +100% | +2/2 | +100% | +1/1 | +100% | +24/24 | +
node-ipc/dao | +
+
+ |
+ 58.75% | +386/657 | +43.14% | +22/51 | +65.22% | +15/23 | +58.75% | +386/657 | +
node-ipc/entities | +
+
+ |
+ 90.72% | +88/97 | +56.25% | +9/16 | +100% | +6/6 | +90.72% | +88/97 | +
node-ipc/helpers | +
+
+ |
+ 100% | +12/12 | +100% | +3/3 | +100% | +1/1 | +100% | +12/12 | +
node-ipc/services | +
+
+ |
+ 51.04% | +172/337 | +50% | +16/32 | +47.62% | +10/21 | +51.04% | +172/337 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
node-ipc | +
+
+ |
+ 100% | +24/24 | +100% | +2/2 | +100% | +1/1 | +100% | +24/24 | +
node-ipc/dao | +
+
+ |
+ 58.75% | +386/657 | +43.14% | +22/51 | +65.22% | +15/23 | +58.75% | +386/657 | +
node-ipc/entities | +
+
+ |
+ 90.72% | +88/97 | +56.25% | +9/16 | +100% | +6/6 | +90.72% | +88/97 | +
node-ipc/helpers | +
+
+ |
+ 100% | +12/12 | +100% | +3/3 | +100% | +1/1 | +100% | +12/12 | +
node-ipc/services | +
+
+ |
+ 51.04% | +172/337 | +50% | +16/32 | +47.62% | +10/21 | +51.04% | +172/337 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 | 2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +3x +3x +3x +3x +3x +3x +3x +3x +3x +2x +2x +3x +3x +3x +3x +3x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + + + +2x +2x + + + + +2x +6x +6x +6x +6x +6x +6x + + + +6x +6x +6x +6x + + + + + + + + + + + +6x +6x +6x +6x +6x + + +6x +6x + + +6x +6x + + +6x +6x + + +6x +6x + + +6x +6x +6x +6x +6x + + + + + + + + + + + + + + + + + + + + + + + + + +6x +6x +6x +6x +6x +6x +6x +5x +5x +5x +5x +6x +6x +6x +6x +6x +1x +1x +1x +1x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +3x +6x +6x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x + + +3x +3x +3x +3x +3x +3x +3x +6x +6x +6x +6x +6x +6x +1x +1x + + + + + + + + + + + +1x +1x +1x +1x +1x +1x +1x +1x + + + +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x +1x + + +1x +6x +6x +2x +2x +2x +2x +2x + | import net from 'net'; +import tls from 'tls'; +import EventParser from '../entities/EventParser.js'; +import Message from 'js-message'; +import fs from 'fs'; +import Queue from 'js-queue'; +import Events from 'event-pubsub'; + +let eventParser = new EventParser(); + +class Client extends Events{ + constructor(config,log){ + super(); + this.config=config; + this.log=log; + this.publish=super.emit; + + (config.maxRetries)? this.retriesRemaining=config.maxRetries:0; + + eventParser=new EventParser(this.config); + } + + Client=Client; + queue =new Queue; + socket=false; + connect=connect; + emit=emit; + retriesRemaining=0; + explicitlyDisconnected=false; +} + +function emit(type,data){ + this.log('dispatching event to ', this.id, this.path, ' : ', type, ',', data); + + let message=new Message; + message.type=type; + message.data=data; + + if(this.config.rawBuffer){ + message=Buffer.from(type,this.config.encoding); + }else{ + message=eventParser.format(message); + } + + //volitile emit + if(!this.config.sync){ + this.socket.write(message); + return; + } + + //sync, non-volitile, ack emit + this.queue.add( + syncEmit.bind(this,message) + ); +} + +function syncEmit(message){ + this.log('dispatching event to ', this.id, this.path, ' : ', message); + this.socket.write(message); +} + +function connect(){ + //init client object for scope persistance especially inside of socket events. + let client=this; + + client.log('requested connection to ', client.id, client.path); + if(!this.path){ + client.log('\n\n######\nerror: ', client.id ,' client has not specified socket path it wishes to connect to.'); + return; + } + + const options={}; + + if(!client.port){ + client.log('Connecting client on Unix Socket :', client.path); + + options.path=client.path; + + if (process.platform ==='win32' && !client.path.startsWith('\\\\.\\pipe\\')){ + options.path = options.path.replace(/^\//, ''); + options.path = options.path.replace(/\//g, '-'); + options.path= `\\\\.\\pipe\\${options.path}`; + } + + client.socket = net.connect(options); + }else{ + options.host=client.path; + options.port=client.port; + + if(client.config.interface.localAddress){ + options.localAddress=client.config.interface.localAddress; + } + + if(client.config.interface.localPort){ + options.localPort=client.config.interface.localPort; + } + + if(client.config.interface.family){ + options.family=client.config.interface.family; + } + + if(client.config.interface.hints){ + options.hints=client.config.interface.hints; + } + + if(client.config.interface.lookup){ + options.lookup=client.config.interface.lookup; + } + + if(!client.config.tls){ + client.log('Connecting client via TCP to', options); + client.socket = net.connect(options); + }else{ + client.log('Connecting client via TLS to', client.path ,client.port,client.config.tls); + if(client.config.tls.private){ + client.config.tls.key=fs.readFileSync(client.config.tls.private); + } + if(client.config.tls.public){ + client.config.tls.cert=fs.readFileSync(client.config.tls.public); + } + if(client.config.tls.trustedConnections){ + if(typeof client.config.tls.trustedConnections === 'string'){ + client.config.tls.trustedConnections=[client.config.tls.trustedConnections]; + } + client.config.tls.ca=[]; + for(let i=0; i<client.config.tls.trustedConnections.length; i++){ + client.config.tls.ca.push( + fs.readFileSync(client.config.tls.trustedConnections[i]) + ); + } + } + + Object.assign(client.config.tls,options); + + client.socket = tls.connect( + client.config.tls + ); + } + } + + client.socket.setEncoding(this.config.encoding); + + client.socket.on( + 'error', + function(err){ + client.log('\n\n######\nerror: ', err); + client.publish('error', err); + + } + ); + + client.socket.on( + 'connect', + function connectionMade(){ + client.publish('connect'); + client.retriesRemaining=client.config.maxRetries; + client.log('retrying reset'); + } + ); + + client.socket.on( + 'close', + function connectionClosed(){ + client.log('connection closed' ,client.id , client.path, + client.retriesRemaining, 'tries remaining of', client.config.maxRetries + ); + + if( + client.config.stopRetrying || + client.retriesRemaining<1 || + client.explicitlyDisconnected + + ){ + client.publish('disconnect'); + client.log( + (client.config.id), + 'exceeded connection rety amount of', + ' or stopRetrying flag set.' + ); + + client.socket.destroy(); + client.publish('destroy'); + client=undefined; + + return; + } + + setTimeout( + function retryTimeout(){ + if (client.explicitlyDisconnected) { + return; + } + client.retriesRemaining--; + client.connect(); + }.bind(null,client), + client.config.retry + ); + + client.publish('disconnect'); + } + ); + + client.socket.on( + 'data', + function(data) { + client.log('## received events ##'); + if(client.config.rawBuffer){ + client.publish( + 'data', + Buffer.from(data,client.config.encoding) + ); + if(!client.config.sync){ + return; + } + + client.queue.next(); + return; + } + + if(!this.ipcBuffer){ + this.ipcBuffer=''; + } + + data=(this.ipcBuffer+=data); + + if(data.slice(-1)!=eventParser.delimiter || data.indexOf(eventParser.delimiter) == -1){ + client.log('Messages are large, You may want to consider smaller messages.'); + return; + } + + this.ipcBuffer=''; + + const events = eventParser.parse(data); + const eCount = events.length; + for(let i=0; i<eCount; i++){ + let message=new Message; + message.load(events[i]); + + client.log('detected event', message.type, message.data); + client.publish( + message.type, + message.data + ); + } + + if(!client.config.sync){ + return; + } + + client.queue.next(); + } + ); +} + +export { + Client as default, + Client +}; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
client.js | +
+
+ |
+ 70.16% | +181/258 | +46.43% | +13/28 | +87.5% | +7/8 | +70.16% | +181/258 | +
socketServer.js | +
+
+ |
+ 51.38% | +205/399 | +39.13% | +9/23 | +53.33% | +8/15 | +51.38% | +205/399 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 | 1x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + +2x +2x +2x + + + +2x +2x +2x +2x +2x +2x +2x + + +2x +2x +2x +1x +1x +1x +1x +1x +1x +1x +1x + + +1x +1x +1x +1x +1x + + + + + + + + + + + + + +1x +1x +1x +2x + + + + + + + + + + + + + + + + + + + + + + +2x + + + + + + + + + + + + + + + + + + + + + + + + + + + + +2x +2x +2x +2x + + + + + + + + +2x +2x +2x +2x +2x +2x +2x +2x + + + +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + + + + +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + + + + + + + + + + + +2x +2x +2x +2x +2x +2x +2x +2x +2x + + +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + +2x + + + + + + + + + + + +2x +2x +2x +2x + + + + + + +2x +2x +2x +2x +2x +2x + + + + + + + + + + + + + + + +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +2x + + + + + + + + + + + + + + + + + + + + + +2x +2x +2x +2x +2x + | +import net from 'net'; +import tls from 'tls'; +import fs from 'fs'; +import dgram from 'dgram'; +import EventParser from '../entities/EventParser.js'; +import Message from 'js-message'; +import Events from 'event-pubsub'; + +let eventParser = new EventParser(); + +class Server extends Events{ + constructor(path,config,log,port){ + super(); + this.config = config; + this.path = path; + this.port = port; + this.log = log; + + this.publish=super.emit; + + eventParser=new EventParser(this.config); + + this.on( + 'close', + serverClosed.bind(this) + ); + } + + udp4=false; + udp6=false; + server=false; + sockets=[]; + emit=emit; + broadcast=broadcast; + + onStart(socket){ + this.publish( + 'start', + socket + ); + } + + stop(){ + this.server.close(); + } + + start(){ + if(!this.path){ + this.log('Socket Server Path not specified, refusing to start'); + return; + } + + if(this.config.unlink){ + fs.unlink( + this.path, + startServer.bind(this) + ); + }else{ + startServer.bind(this)(); + } + } +} + +function emit(socket, type, data){ + this.log('dispatching event to socket', ' : ', type, data); + + let message=new Message; + message.type=type; + message.data=data; + + if(this.config.rawBuffer){ + this.log(this.config.encoding) + message=Buffer.from(type,this.config.encoding); + }else{ + message=eventParser.format(message); + } + + if(this.udp4 || this.udp6){ + + if(!socket.address || !socket.port){ + this.log('Attempting to emit to a single UDP socket without supplying socket address or port. Redispatching event as broadcast to all connected sockets'); + this.broadcast(type,data); + return; + } + + this.server.write( + message, + socket + ); + return; + } + + socket.write(message); +} + +function broadcast(type,data){ + this.log('broadcasting event to all known sockets listening to ', this.path,' : ', ((this.port)?this.port:''), type, data); + let message=new Message; + message.type=type; + message.data=data; + + if(this.config.rawBuffer){ + message=Buffer.from(type,this.config.encoding); + }else{ + message=eventParser.format(message); + } + + if(this.udp4 || this.udp6){ + for(let i=1, count=this.sockets.length; i<count; i++){ + this.server.write(message,this.sockets[i]); + } + }else{ + for(let i=0, count=this.sockets.length; i<count; i++){ + this.sockets[i].write(message); + } + } +} + +function serverClosed(){ + for(let i=0, count=this.sockets.length; i<count; i++){ + let socket=this.sockets[i]; + let destroyedSocketId=false; + + if(socket){ + if(socket.readable){ + continue; + } + } + + if(socket.id){ + destroyedSocketId=socket.id; + } + + this.log('socket disconnected',destroyedSocketId.toString()); + + if(socket && socket.destroy){ + socket.destroy(); + } + + this.sockets.splice(i,1); + + this.publish('socket.disconnected', socket, destroyedSocketId); + + return; + } +} + +function gotData(socket,data,UDPSocket){ + let sock=((this.udp4 || this.udp6)? UDPSocket : socket); + if(this.config.rawBuffer){ + data=Buffer.from(data,this.config.encoding); + this.publish( + 'data', + data, + sock + ); + return; + } + + if(!sock.ipcBuffer){ + sock.ipcBuffer=''; + } + + data=(sock.ipcBuffer+=data); + + if(data.slice(-1)!=eventParser.delimiter || data.indexOf(eventParser.delimiter) == -1){ + this.log('Messages are large, You may want to consider smaller messages.'); + return; + } + + sock.ipcBuffer=''; + + data=eventParser.parse(data); + + while(data.length>0){ + let message=new Message; + message.load(data.shift()); + + // Only set the sock id if it is specified. + if (message.data && message.data.id){ + sock.id=message.data.id; + } + + this.log('received event of : ',message.type,message.data); + + this.publish( + message.type, + message.data, + sock + ); + } +} + +function socketClosed(socket){ + this.publish( + 'close', + socket + ); +} + +function serverCreated(socket) { + this.sockets.push(socket); + + if(socket.setEncoding){ + socket.setEncoding(this.config.encoding); + } + + this.log('## socket connection to server detected ##'); + socket.on( + 'close', + socketClosed.bind(this) + ); + + socket.on( + 'error', + function(err){ + this.log('server socket error',err); + + this.publish('error',err); + }.bind(this) + ); + + socket.on( + 'data', + gotData.bind(this,socket) + ); + + socket.on( + 'message', + function(msg,rinfo) { + if (!rinfo){ + return; + } + + this.log('Received UDP message from ', rinfo.address, rinfo.port); + let data; + + if(this.config.rawSocket){ + data=Buffer.from(msg,this.config.encoding); + }else{ + data=msg.toString(); + } + socket.emit('data',data,rinfo); + }.bind(this) + ); + + this.publish( + 'connect', + socket + ); + + if(this.config.rawBuffer){ + return; + } +} + +function startServer() { + this.log( + 'starting server on ',this.path, + ((this.port)?`:${this.port}`:'') + ); + + if(!this.udp4 && !this.udp6){ + this.log('starting TLS server',this.config.tls); + if(!this.config.tls){ + this.server=net.createServer( + serverCreated.bind(this) + ); + }else{ + startTLSServer.bind(this)(); + } + }else{ + this.server=dgram.createSocket( + ((this.udp4)? 'udp4':'udp6') + ); + this.server.write=UDPWrite.bind(this); + this.server.on( + 'listening', + function UDPServerStarted() { + serverCreated.bind(this)(this.server); + }.bind(this) + ); + } + + this.server.on( + 'error', + function(err){ + this.log('server error',err); + + this.publish( + 'error', + err + ); + }.bind(this) + ); + + this.server.maxConnections=this.config.maxConnections; + + if(!this.port){ + this.log('starting server as', 'Unix || Windows Socket'); + if (process.platform ==='win32'){ + this.path = this.path.replace(/^\//, ''); + this.path = this.path.replace(/\//g, '-'); + this.path= `\\\\.\\pipe\\${this.path}`; + } + + this.server.listen({ + path: this.path, + readableAll: true, + writableAll: true + }, this.onStart.bind(this)); + + return; + } + + if(!this.udp4 && !this.udp6){ + this.log('starting server as', (this.config.tls?'TLS':'TCP')); + this.server.listen( + this.port, + this.path, + this.onStart.bind(this) + ); + return; + } + + this.log('starting server as',((this.udp4)? 'udp4':'udp6')); + + this.server.bind( + this.port, + this.path + ); + + this.onStart( + { + address : this.path, + port : this.port + } + ); +} + +function startTLSServer(){ + this.log('starting TLS server',this.config.tls); + if(this.config.tls.private){ + this.config.tls.key=fs.readFileSync(this.config.tls.private); + }else{ + this.config.tls.key=fs.readFileSync(`${__dirname}/../local-node-ipc-certs/private/server.key`); + } + if(this.config.tls.public){ + this.config.tls.cert=fs.readFileSync(this.config.tls.public); + }else{ + this.config.tls.cert=fs.readFileSync(`${__dirname}/../local-node-ipc-certs/server.pub`); + } + if(this.config.tls.dhparam){ + this.config.tls.dhparam=fs.readFileSync(this.config.tls.dhparam); + } + if(this.config.tls.trustedConnections){ + if(typeof this.config.tls.trustedConnections === 'string'){ + this.config.tls.trustedConnections=[this.config.tls.trustedConnections]; + } + this.config.tls.ca=[]; + for(let i=0; i<this.config.tls.trustedConnections.length; i++){ + this.config.tls.ca.push( + fs.readFileSync(this.config.tls.trustedConnections[i]) + ); + } + } + this.server=tls.createServer( + this.config.tls, + serverCreated.bind(this) + ); +} + +function UDPWrite(message,socket){ + let data=Buffer.from(message, this.config.encoding); + this.server.send( + data, + 0, + data.length, + socket.port, + socket.address, + function(err, bytes) { + if(err){ + this.log('error writing data to socket',err); + this.publish( + 'error', + function(err){ + this.publish('error',err); + } + ); + } + } + ); +} + +export { + Server as default, + Server +}; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 | 2x +2x +2x +2x +2x +10x +10x +2x +2x +2x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +10x +2x +2x +2x +10x +10x +10x +10x +10x +10x + + + + + +10x +10x +2x +2x +2x +2x +2x + | import os from 'os'; + +class Defaults{ + + constructor(){ + + } + + + appspace='app.'; + socketRoot='/tmp/'; + id=os.hostname(); + + encoding='utf8'; + rawBuffer=false; + sync=false; + unlink=true; + + delimiter='\f'; + + silent=false; + logDepth=5; + logInColor=true; + logger=console.log.bind(console); + + maxConnections=100; + retry=500; + maxRetries=Infinity; + stopRetrying=false; + + IPType=getIPType(); + tls=false; + networkHost = (this.IPType == 'IPv6') ? '::1' : '127.0.0.1'; + networkPort = 8000; + + interface={ + localAddress:false, + localPort:false, + family:false, + hints:false, + lookup:false + } + +} + +function getIPType() { + const networkInterfaces = os.networkInterfaces(); + let IPType = ''; + if (networkInterfaces + && Array.isArray(networkInterfaces) + && networkInterfaces.length > 0) { + // getting the family of first network interface available + IPType = networkInterfaces [ + Object.keys( networkInterfaces )[0] + ][0].family; + } + return IPType; +} + +export { + Defaults as default, + Defaults +} + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 | 1x +2x +2x +2x +2x +9x +4x +4x +9x +9x +2x +2x +3x + + +3x + + +3x +3x +3x +3x +2x +2x +3x +3x +3x +3x +2x +2x +2x +2x +2x +2x + | +import Defaults from './Defaults.js'; + +class Parser{ + constructor(config){ + if(!config){ + config=new Defaults; + } + this.delimiter=config.delimiter; + } + + format(message){ + if(!message.data && message.data!==false && message.data!==0){ + message.data={}; + } + if(message.data['_maxListeners']){ + message.data={}; + } + + message=message.JSON+this.delimiter; + return message; + } + + parse(data){ + let events=data.split(this.delimiter); + events.pop(); + return events; + } +} + +export { + Parser as default, + Parser +}; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
Defaults.js | +
+
+ |
+ 92.06% | +58/63 | +57.14% | +4/7 | +100% | +3/3 | +92.06% | +58/63 | +
EventParser.js | +
+
+ |
+ 88.24% | +30/34 | +55.56% | +5/9 | +100% | +3/3 | +88.24% | +30/34 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 | 4x +4x +4x +4x +4x +4x +4x +1x +1x +1x +1x +1x | async function delay(ms=100) { + return new Promise( + resolve => { + setTimeout(resolve, ms); + } + ); +} + +export { + delay as default, + delay +} |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
delay.js | +
+
+ |
+ 100% | +12/12 | +100% | +3/3 | +100% | +1/1 | +100% | +12/12 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
node-ipc.js | +
+
+ |
+ 100% | +24/24 | +100% | +2/2 | +100% | +1/1 | +100% | +24/24 | +
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 | 2x +2x +2x +2x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +6x +2x +2x +2x +2x +2x +2x +2x +2x + | import IPC from './services/IPC.js'; + +class IPCModule extends IPC{ + constructor(){ + super(); + //include IPC to make extensible + Object.defineProperty( + this, + 'IPC', + { + enumerable:true, + writable:false, + value:IPC + } + ) + } +} + +const singleton=new IPCModule; + +export { + singleton as default, + IPCModule +} + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 | 1x +2x +2x +2x +2x +2x +2x +2x +6x +6x +2x +2x +2x +6x +2x +2x +2x +2x + + +2x +3x +3x +2x +3x +3x +2x + + +2x +2x +2x +2x +10x +10x +2x +2x + + +2x + + +2x + + +2x + + +2x + + +2x + + +2x +2x +2x +2x +49x +49x +9x +9x +40x +40x +127x +113x +113x +14x +14x +14x +14x +14x +14x +14x +14x +14x +40x +40x +40x +40x +49x +2x +3x +3x + + +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +2x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +2x + + + +2x +2x +2x + + + + + +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + + + +2x +2x + + + + +2x + + + + +2x +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + +2x +2x + + +2x +2x +2x +2x +2x +2x +2x +2x +2x + + + + + + +2x +2x +2x +2x +2x +2x +2x + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +2x +3x +3x + + + + + + +3x +3x +3x +3x +3x +3x + + + + +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x + + + +3x + + + + + + + +3x +3x + + + +3x + + +3x +3x + + + + + + + + + + + + +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +3x +2x +2x +2x +2x +2x + | +import Defaults from '../entities/Defaults.js'; +import Client from '../dao/client.js'; +import Server from '../dao/socketServer.js'; +import util from 'util'; + +class IPC{ + constructor(){ + + } + + //public members + config=new Defaults; + of={}; + server=false; + + //protected methods + get connectTo(){ + return connect; + } + get connectToNet(){ + return connectNet; + } + get disconnect(){ + return disconnect + } + get serve(){ + return serve; + } + get serveNet(){ + return serveNet; + } + get log(){ + return log; + } + + set connectTo(value){ + return connect; + } + set connectToNet(value){ + return connectNet; + } + set disconnect(value){ + return disconnect + } + set serve(value){ + return serve; + } + set serveNet(value){ + return serveNet; + } + set log(value){ + return log; + } +} + + + +function log(...args){ + if(this.config.silent){ + return; + } + + for(let i=0, count=args.length; i<count; i++){ + if(typeof args[i] != 'object'){ + continue; + } + + args[i]=util.inspect( + args[i], + { + depth:this.config.logDepth, + colors:this.config.logInColor + } + ); + } + + this.config.logger( + args.join(' ') + ); +} + +function disconnect(id){ + if(!this.of[id]){ + return; + } + + this.of[id].explicitlyDisconnected=true; + + this.of[id].off('*','*'); + if(this.of[id].socket){ + if(this.of[id].socket.destroy){ + this.of[id].socket.destroy(); + } + } + + delete this.of[id]; +} + +function serve(path,callback){ + if(typeof path=='function'){ + callback=path; + path=false; + } + if(!path){ + this.log( + 'Server path not specified, so defaulting to', + 'ipc.config.socketRoot + ipc.config.appspace + ipc.config.id', + this.config.socketRoot+this.config.appspace+this.config.id + ); + path=this.config.socketRoot+this.config.appspace+this.config.id; + } + + if(!callback){ + callback=emptyCallback; + } + + this.server=new Server( + path, + this.config, + log + ); + + this.server.on( + 'start', + callback + ); +} + +function emptyCallback(){ + //Do Nothing +} + +function serveNet(host,port,UDPType,callback){ + if(typeof host=='number'){ + callback=UDPType; + UDPType=port; + port=host; + host=false; + } + if(typeof host=='function'){ + callback=host; + UDPType=false; + host=false; + port=false; + } + if(!host){ + this.log( + 'Server host not specified, so defaulting to', + 'ipc.config.networkHost', + this.config.networkHost + ); + host=this.config.networkHost; + } + if(host.toLowerCase()=='udp4' || host.toLowerCase()=='udp6'){ + callback=port; + UDPType=host.toLowerCase(); + port=false; + host=this.config.networkHost; + } + + if(typeof port=='string'){ + callback=UDPType; + UDPType=port; + port=false; + } + if(typeof port=='function'){ + callback=port; + UDPType=false; + port=false; + } + if(!port){ + this.log( + 'Server port not specified, so defaulting to', + 'ipc.config.networkPort', + this.config.networkPort + ); + port=this.config.networkPort; + } + + if(typeof UDPType=='function'){ + callback=UDPType; + UDPType=false; + } + + if(!callback){ + callback=emptyCallback; + } + + this.server=new Server( + host, + this.config, + log, + port + ); + + if(UDPType){ + this.server[UDPType]=true; + if(UDPType === "udp4" && host === "::1") { + // bind udp4 socket to an ipv4 address + this.server.path = "127.0.0.1"; + } + } + + this.server.on( + 'start', + callback + ); +} + +function connect(id,path,callback){ + if(typeof path == 'function'){ + callback=path; + path=false; + } + + if(!callback){ + callback=emptyCallback; + } + + if(!id){ + this.log( + 'Service id required', + 'Requested service connection without specifying service id. Aborting connection attempt' + ); + return; + } + + if(!path){ + this.log( + 'Service path not specified, so defaulting to', + 'ipc.config.socketRoot + ipc.config.appspace + id', + (this.config.socketRoot+this.config.appspace+id).data + ); + path=this.config.socketRoot+this.config.appspace+id; + } + + if(this.of[id]){ + if(!this.of[id].socket.destroyed){ + this.log( + 'Already Connected to', + id, + '- So executing success without connection' + ); + callback(); + return; + } + this.of[id].socket.destroy(); + } + + this.of[id] = new Client(this.config,this.log); + this.of[id].id = id; + (this.of[id].socket)? (this.of[id].socket.id=id):null; + this.of[id].path = path; + + this.of[id].connect(); + + callback(this); +} + +function connectNet(id,host,port,callback){ + if(!id){ + this.log( + 'Service id required', + 'Requested service connection without specifying service id. Aborting connection attempt' + ); + return; + } + if(typeof host=='number'){ + callback=port; + port=host; + host=false; + } + if(typeof host=='function'){ + callback=host; + host=false; + port=false; + } + if(!host){ + this.log( + 'Server host not specified, so defaulting to', + 'ipc.config.networkHost', + this.config.networkHost + ); + host=this.config.networkHost; + } + + if(typeof port=='function'){ + callback=port; + port=false; + } + if(!port){ + this.log( + 'Server port not specified, so defaulting to', + 'ipc.config.networkPort', + this.config.networkPort + ); + port=this.config.networkPort; + } + + if(typeof callback == 'string'){ + UDPType=callback; + callback=false; + } + if(!callback){ + callback=emptyCallback; + } + + if(this.of[id]){ + if(!this.of[id].socket.destroyed){ + + this.log( + 'Already Connected to', + id, + '- So executing success without connection' + ); + callback(); + return; + } + this.of[id].socket.destroy(); + } + + this.of[id] = new Client(this.config,this.log); + this.of[id].id = id; + (this.of[id].socket)? (this.of[id].socket.id=id):null; + this.of[id].path = host; + this.of[id].port = port; + + this.of[id].connect(); + + callback(this); +} + +export { + IPC as default, + IPC +}; + |
+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +
+File | ++ | Statements | ++ | Branches | ++ | Functions | ++ | Lines | ++ |
---|---|---|---|---|---|---|---|---|---|
IPC.js | +
+
+ |
+ 51.04% | +172/337 | +50% | +16/32 | +47.62% | +10/21 | +51.04% | +172/337 | +