This commit is contained in:
commit
4cf5906e95
26 changed files with 77 additions and 749 deletions
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"sbruchmann.staticpreview.basepath": "/home/bmiller/git/node-ipc/"
|
||||
}
|
15
README.md
15
README.md
|
@ -8,6 +8,7 @@ A great solution for **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)
|
||||
|
@ -150,7 +151,7 @@ You can override any of these settings by requireing colors and setting the them
|
|||
|
||||
`ipc.connectTo(id,path,callback);`
|
||||
|
||||
Used for connecting as a client to local Unix Sockets and Windows Sockets. ***This is the fastst way for processes on the same machine to communicate*** because it bypasses the network card which TCP and UDP must both use.
|
||||
Used for connecting as a client to local Unix Sockets and Windows Sockets. ***This is the fastest way for processes on the same machine to communicate*** because it bypasses the network card which TCP and UDP must both use.
|
||||
|
||||
| variable | required | definition |
|
||||
|----------|----------|------------|
|
||||
|
@ -354,8 +355,8 @@ Used to create TCP, TLS or UDP Socket Server to which Clients can bind or other
|
|||
| variable | required | definition |
|
||||
|----------|----------|------------|
|
||||
| host | optional | If not specified this defaults to the first address in os.networkInterfaces(). For TCP, TLS & UDP servers this is most likely going to be 127.0.0.1 or ::1 |
|
||||
| port | optional | The port on wunich the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified |
|
||||
| UDPType | optional | If set this will create the server as a UDP socket. 'udp4' or 'udp6' are valid values. This defaults to not being set.
|
||||
| port | optional | The port on which the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified |
|
||||
| UDPType | optional | If set this will create the server as a UDP socket. 'udp4' or 'udp6' are valid values. This defaults to not being set. When using udp6 make sure to specify a valid IPv6 host, like ` ::1 ` |
|
||||
| callback | optional | Function to be called when the server is created |
|
||||
|
||||
***examples*** arguments can be ommitted solong as they are still in order.
|
||||
|
@ -440,6 +441,14 @@ or specifying everything UDP
|
|||
| ipc.of | This is where socket connection refrences will be stored when connecting to them as a client via the `ipc.connectTo` or `iupc.connectToNet`. They will be stored based on the ID used to create them, eg : ipc.of.mySocket|
|
||||
| ipc.server| This is a refrence to the server created by `ipc.serve` or `ipc.serveNet`|
|
||||
|
||||
----
|
||||
### IPC Server Methods
|
||||
|
||||
| method | definition |
|
||||
|-----------|------------|
|
||||
|start| start serving need top call ` serve ` or ` serveNet ` first to set up the server |
|
||||
|stop| close the server and stop serving |
|
||||
|
||||
----
|
||||
|
||||
### IPC Events
|
||||
|
|
|
@ -9,6 +9,7 @@ var ipc=require('../../../node-ipc');
|
|||
|
||||
ipc.config.id = 'world';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.maxConnections=1;
|
||||
|
||||
ipc.serveNet(
|
||||
function(){
|
||||
|
@ -33,4 +34,11 @@ ipc.serveNet(
|
|||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'error',
|
||||
function(err){
|
||||
ipc.log('Got an ERROR!'.warn,err)
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.start();
|
||||
|
|
|
@ -10,8 +10,8 @@ var ipc=require('../../../node-ipc');
|
|||
ipc.config.id = 'world';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key'
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||
}
|
||||
|
||||
var messages={
|
||||
|
|
|
@ -10,11 +10,11 @@ var ipc=require('../../../node-ipc');
|
|||
ipc.config.id = 'hello';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.tls={
|
||||
private: '../../../local-node-ipc-certs/private/client.key',
|
||||
public: '../../../local-node-ipc-certs/client.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/client.pub',
|
||||
rejectUnauthorized:false,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/server.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/server.pub'
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
@ -10,13 +10,13 @@ var ipc=require('../../../node-ipc');
|
|||
ipc.config.id = 'world';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: '../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
requestCert: true,
|
||||
rejectUnauthorized:false,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/client.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@ ipc.config.id = 'hello';
|
|||
ipc.config.retry= 1500;
|
||||
ipc.config.networkHost='localhost';
|
||||
ipc.config.tls={
|
||||
private: '../../../local-node-ipc-certs/private/client.key',
|
||||
public: '../../../local-node-ipc-certs/client.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/client.pub',
|
||||
rejectUnauthorized:true,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/server.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/server.pub'
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ ipc.config.id = 'world';
|
|||
ipc.config.retry= 1500;
|
||||
ipc.config.networkHost='localhost';
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: '../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
requestCert: true,
|
||||
rejectUnauthorized:true,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/client.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ var ipc=require('../../../node-ipc');
|
|||
ipc.config.id = 'world';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key'
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||
}
|
||||
|
||||
ipc.serveNet(
|
||||
|
|
|
@ -11,8 +11,8 @@ ipc.config.id = 'world';
|
|||
ipc.config.retry= 1500;
|
||||
ipc.config.sync= true;
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key'
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||
}
|
||||
|
||||
ipc.serveNet(
|
||||
|
|
|
@ -14,11 +14,11 @@ ipc.config.encoding='ascii';
|
|||
ipc.config.networkHost='localhost';
|
||||
|
||||
ipc.config.tls={
|
||||
private: '../../../local-node-ipc-certs/private/client.key',
|
||||
public: '../../../local-node-ipc-certs/client.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/client.pub',
|
||||
rejectUnauthorized:true,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/server.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/server.pub'
|
||||
]
|
||||
};
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@ ipc.config.encoding='ascii';
|
|||
ipc.config.networkHost='localhost';
|
||||
|
||||
ipc.config.tls={
|
||||
public: '../../../local-node-ipc-certs/server.pub',
|
||||
private: '../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: '../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key',
|
||||
dhparam: __dirname+'/../../../local-node-ipc-certs/private/dhparam.pem',
|
||||
requestCert: true,
|
||||
rejectUnauthorized:true,
|
||||
trustedConnections: [
|
||||
'../../../local-node-ipc-certs/client.pub'
|
||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -78,6 +78,9 @@ function init(path,config,log,port){
|
|||
socket
|
||||
);
|
||||
},
|
||||
stop:function(){
|
||||
server.server.close();
|
||||
},
|
||||
start : function(){
|
||||
if(!this.path){
|
||||
server.log('Socket Server Path not specified, refusing to start'.warn);
|
||||
|
@ -138,6 +141,7 @@ function init(path,config,log,port){
|
|||
socket.address,
|
||||
function(err, bytes) {
|
||||
if(err){
|
||||
server.log('error writing data to socket'.warn,err);
|
||||
server.trigger(
|
||||
'error',
|
||||
function(err){
|
||||
|
@ -161,6 +165,20 @@ function init(path,config,log,port){
|
|||
);
|
||||
}
|
||||
|
||||
server.server.on(
|
||||
'error',
|
||||
function(err){
|
||||
server.log('server error'.warn,err);
|
||||
|
||||
server.trigger(
|
||||
'error',
|
||||
err
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
server.server.maxConnections=server.config.maxConnections;
|
||||
|
||||
function serverCreated(socket) {
|
||||
server.sockets.push(socket);
|
||||
|
||||
|
@ -181,6 +199,8 @@ function init(path,config,log,port){
|
|||
socket.on(
|
||||
'error',
|
||||
function(err){
|
||||
server.log('server socket error'.warn,err);
|
||||
|
||||
server.trigger('error',err);
|
||||
}
|
||||
);
|
||||
|
@ -275,11 +295,10 @@ function init(path,config,log,port){
|
|||
started
|
||||
);
|
||||
|
||||
server.server.maxConnections=server.maxConnections;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!server.udp4 && !server.udp4){
|
||||
if(!server.udp4 && !server.udp6){
|
||||
server.log('starting server as'.debug, (server.config.tls?'TLS':'TCP').variable);
|
||||
server.server.listen(
|
||||
server.port,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "node-ipc",
|
||||
"version": "5.0.0",
|
||||
"version": "5.2.0",
|
||||
"description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.",
|
||||
"main": "node-ipc.js",
|
||||
"directories": {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
#node-ipc test harness
|
||||
***TestHarness was intended to be run on linux.***
|
||||
*the test.js file is intended to start and run all of the files in the test folder*
|
||||
|
||||
A full regression test should be done before each release to npm to insure that no expected or previously documented bugs pop up again.
|
||||
This will also help to ensure that each new release does not create any additional bugs. However, it can never fully ensure no new bugs will be created.
|
||||
Any bug that is reported and testable, which should be 99.9% of bugs, should have a test written and added to the test folder after fixing.
|
||||
|
||||
> Written with [StackEdit](https://stackedit.io/).
|
|
@ -1,170 +0,0 @@
|
|||
var ipc = require('../node-ipc'),
|
||||
cmd = require('node-cmd'),
|
||||
fs = require('fs'),
|
||||
tests = {},
|
||||
testCount=0,
|
||||
fails=[],
|
||||
passes=[],
|
||||
debug=true;
|
||||
|
||||
ipc.config.id = 'testHarness';
|
||||
|
||||
ipc.serve(
|
||||
function(){
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'pass',
|
||||
function(test,socket){
|
||||
ipc.log(socket.id.good,'passed',test.data);
|
||||
tests[socket.id].pass.push(test);
|
||||
passes.push(test);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'fail',
|
||||
function(test,socket){
|
||||
ipc.log(socket.id.warn,'failed',test.data);
|
||||
tests[socket.id].fail.push(test);
|
||||
fails.push(test);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'start.test',
|
||||
function(data,socket){
|
||||
|
||||
socket.id=data.id;
|
||||
|
||||
if(!data.id){
|
||||
ipc.log('start.test duration not passed for unknown test, so failing test'.error);
|
||||
socket.destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!data.duration){
|
||||
ipc.log(data.id.notice, 'start.test duration not passed, so failing test'.error);
|
||||
ipc.disconnect(data.id);
|
||||
return;
|
||||
}
|
||||
|
||||
ipc.log(data.id.notice, 'started'.debug);
|
||||
|
||||
tests[data.id].started=true;
|
||||
clearTimeout(
|
||||
tests[data.id].delay
|
||||
);
|
||||
|
||||
tests[data.id].delay=setTimeout(
|
||||
(
|
||||
function(test){
|
||||
return function(){
|
||||
ipc.log(test.warn," failed to complete ".error);
|
||||
tests[test].fail.push('end.test');
|
||||
fails.push(test+' >> end.test');
|
||||
testCount--;
|
||||
tests[socket.id].delay=null;
|
||||
checkComplete();
|
||||
}
|
||||
}
|
||||
)(data.id),
|
||||
data.duration
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'end.test',
|
||||
function(data,socket){
|
||||
ipc.log(socket.id.notice, 'completed'.debug);
|
||||
clearTimeout(
|
||||
tests[socket.id].delay
|
||||
);
|
||||
|
||||
tests[socket.id].delay=null;
|
||||
|
||||
testCount--;
|
||||
checkComplete();
|
||||
}
|
||||
);
|
||||
|
||||
ipc.log('TestHarness started.'.debug, 'Loading Tests.'.notice);
|
||||
|
||||
ipc.server.define.listen['start.test']='This event should be called when a test is starting. It accepts an object with test details including the test id and duration';
|
||||
ipc.server.define.listen['end.test']='This event should be called when a test is completed.';
|
||||
ipc.server.define.listen['pass']='This event should be called when a test has passed, it accepts the name of the test portion which passed';
|
||||
ipc.server.define.listen['fail']='This event should be called when a test has failed, it accepts the name of the test portion which failed';
|
||||
|
||||
ipc.server.start();
|
||||
|
||||
fs.readdir(
|
||||
'tests',
|
||||
function(err,testFolders){
|
||||
if(err){
|
||||
ipc.log(err,'You must execute the testHarness from the testHarness directory'.error)
|
||||
return;
|
||||
}
|
||||
testCount=testFolders.length;
|
||||
|
||||
for(var i =0; i<testFolders.length; i++){
|
||||
tests[testFolders[i]]={
|
||||
started : false,
|
||||
pass : [],
|
||||
fail : [],
|
||||
delay : setTimeout(
|
||||
(
|
||||
function(test){
|
||||
return function(){
|
||||
ipc.log(test.warn," failed to start ".error);
|
||||
tests[test].fail.push('start.test');
|
||||
fails.push(test+' >> start.test');
|
||||
testCount--;
|
||||
checkComplete();
|
||||
}
|
||||
}
|
||||
)(testFolders[i]),
|
||||
1000
|
||||
)
|
||||
};
|
||||
|
||||
runTests(testFolders[i])
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
function runTests(dir){
|
||||
fs.readdir(
|
||||
'tests/'+dir,
|
||||
function(err,testFiles){
|
||||
if(err){
|
||||
ipc.log(err,'You must execute the testHarness from the testHarness directory'.error)
|
||||
return;
|
||||
}
|
||||
for(var i =0; i<testFiles.length; i++){
|
||||
cmd.run(
|
||||
'node tests/'+dir+'/'+testFiles[i]
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function checkComplete(){
|
||||
if(testCount)
|
||||
return;
|
||||
|
||||
ipc.log('####################################\n\n RESULTS\n\n####################################\n\n'.rainbow,tests,'\n\n');
|
||||
ipc.log('####################################\n\n PASSES\n\n####################################\n\n'.good,passes.join('\n').good,'\n\n');
|
||||
ipc.log('####################################\n\n FAILS\n\n####################################\n\n'.warn,fails.join('\n').warn,'\n\n');
|
||||
ipc.log('####################################\n\n PASS/FAIL COUNT\n\n####################################\n\n'.data,(passes.length+' ').good,(fails.length+' ').warn,'\n\n');
|
||||
|
||||
fs.unlink('/tmp/app.testHarness');
|
||||
fs.unlink('/tmp/app.stopRetrieing-unix-socket-test');
|
||||
fs.unlink('/tmp/app.unix-socket-test');
|
||||
|
||||
if(!debug)
|
||||
process.exit(0);
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
var ipc = require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
ipc.config.stopRetrying=true;
|
||||
|
||||
//Wait to connect to ensure test server is started
|
||||
setTimeout(
|
||||
function(){
|
||||
ipc.connectTo(
|
||||
server,
|
||||
function(){
|
||||
ipc.of[server].on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.disconnect(server);
|
||||
|
||||
//wait long enough that the test will fail if disconnect does not happen
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
2000
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
400
|
||||
);
|
|
@ -1,48 +0,0 @@
|
|||
var ipc = require('../../../node-ipc'),
|
||||
expectedClient=ipc.config.id+'-client';
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1800
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serve(
|
||||
function(){
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'socket.disconnected',
|
||||
function(socket,id){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'stopRetrying-unix-server'
|
||||
);
|
||||
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.start();
|
|
@ -1,39 +0,0 @@
|
|||
var ipc=require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
ipc.config.maxRetries=50;
|
||||
|
||||
ipc.connectToNet(
|
||||
server,
|
||||
function(){
|
||||
ipc.of[server].on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of[server].emit(
|
||||
'test-test',
|
||||
{
|
||||
id:ipc.config.id
|
||||
}
|
||||
);
|
||||
|
||||
//wait to ensure above event has opportunity to tranfer and register client properly
|
||||
setTimeout(
|
||||
function(){
|
||||
ipc.disconnect(server);
|
||||
},
|
||||
100
|
||||
);
|
||||
|
||||
//wait long enough that the test will fail if disconnect does not happen
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
2000
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
|
@ -1,92 +0,0 @@
|
|||
var ipc=require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
expectedClient=ipc.config.id+'-client';
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1200
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serveNet(
|
||||
function(){
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'tcp-server-connection'
|
||||
);
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.on(
|
||||
'socket.disconnected',
|
||||
function(socket,id){
|
||||
var test='tcp-server-detected-correct-id-disconnection';
|
||||
if(id==ipc.config.id+'-client'){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.on(
|
||||
'test-test',
|
||||
function(data,socket){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'tcp-client-message'
|
||||
);
|
||||
|
||||
var test='tcp-client-registered with proper id'
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.define.listen.message='This event type listens for message strings as value of data key.';
|
||||
|
||||
ipc.server.start();
|
|
@ -1,42 +0,0 @@
|
|||
var ipc = require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1200
|
||||
}
|
||||
);
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'test-harness-pass-test'
|
||||
);
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
'test-harness-this-test-should-fail'
|
||||
);
|
||||
setTimeout(
|
||||
function(){
|
||||
//delay exit incase you want to test failure of start.test by modifying event name
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
ipc.of.testHarness.disconnect();
|
||||
},
|
||||
1000
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
var ipc=require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
|
||||
ipc.serveNet(
|
||||
8002, // tcp test uses default of 8000 udp server.js using 8001 increment to ensure no collision
|
||||
'udp4',
|
||||
function(){
|
||||
setTimeout( //wait to ensure UDP server.js running
|
||||
function(){
|
||||
ipc.server.emit(
|
||||
{
|
||||
address : 'localhost',
|
||||
port : 8001
|
||||
},
|
||||
'test-test',
|
||||
{
|
||||
id : ipc.config.id
|
||||
}
|
||||
);
|
||||
|
||||
setTimeout( //wait to ensure test-test event sent
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
);
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.start();
|
|
@ -1,101 +0,0 @@
|
|||
var ipc=require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
var expectedClient=ipc.config.id+'-client'
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1200
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serveNet(
|
||||
8001, // tcp test uses default of 8000 increment to ensure no collision
|
||||
'udp4',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'udp-server-started'
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'test-test',
|
||||
function(data,socket){
|
||||
var event={
|
||||
id : 'udp-client-id',
|
||||
address : 'udp-client-address',
|
||||
port : 'udp-client-port'
|
||||
}
|
||||
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'udp-client-message'
|
||||
);
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.id
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.id+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
|
||||
if(socket.address=='127.0.0.1'){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.address
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.port
|
||||
);
|
||||
}
|
||||
|
||||
if(socket.port==8002){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
event.port
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
event.port
|
||||
);
|
||||
}
|
||||
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
setTimeout( //wait to ensure events sent to testHarness
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.start();
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
|
@ -1,39 +0,0 @@
|
|||
var ipc = require('../../../node-ipc'),
|
||||
server=__dirname.split('/'),
|
||||
server=server[server.length-1]
|
||||
|
||||
ipc.config.id = server+'-client';
|
||||
ipc.config.maxRetries=50;
|
||||
|
||||
ipc.connectTo(
|
||||
server,
|
||||
function(){
|
||||
ipc.of[server].on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of[server].emit(
|
||||
'test-test',
|
||||
{
|
||||
id:ipc.config.id
|
||||
}
|
||||
);
|
||||
|
||||
//wait to ensure above event has opportunity to tranfer and register client properly
|
||||
setTimeout(
|
||||
function(){
|
||||
ipc.disconnect(server);
|
||||
},
|
||||
100
|
||||
);
|
||||
|
||||
//wait long enough that the test will fail if disconnect does not happen
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
2000
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
|
@ -1,97 +0,0 @@
|
|||
var ipc = require('../../../node-ipc');
|
||||
|
||||
ipc.config.id = __dirname.split('/');
|
||||
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
||||
ipc.config.maxRetries=1;
|
||||
|
||||
var expectedClient=ipc.config.id+'-client';
|
||||
|
||||
ipc.connectTo(
|
||||
'testHarness',
|
||||
function(){
|
||||
ipc.of.testHarness.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'start.test',
|
||||
{
|
||||
id : ipc.config.id,
|
||||
duration: 1400
|
||||
}
|
||||
);
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
|
||||
ipc.serve(
|
||||
function(){
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.on(
|
||||
'connect',
|
||||
function(){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'unix-server-connection'
|
||||
);
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.on(
|
||||
'socket.disconnected',
|
||||
function(socket,id){
|
||||
var test='unix-server-detected-correct-id-disconnection';
|
||||
if(id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
ipc.of.testHarness.emit(
|
||||
'end.test'
|
||||
);
|
||||
|
||||
setTimeout(
|
||||
function(){
|
||||
process.exit(0);
|
||||
},
|
||||
400
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
ipc.server.on(
|
||||
'test-test',
|
||||
function(data,socket){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
'unix-client-message'
|
||||
);
|
||||
|
||||
var test='unix-client-registered with proper id'
|
||||
|
||||
if(socket.id==expectedClient){
|
||||
ipc.of.testHarness.emit(
|
||||
'pass',
|
||||
test
|
||||
);
|
||||
}else{
|
||||
ipc.of.testHarness.emit(
|
||||
'fail',
|
||||
test+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.define.listen['test-test']='Registers and tests ipc communication.';
|
||||
|
||||
ipc.server.start();
|
Loading…
Reference in a new issue