clean up
This commit is contained in:
parent
97d1e0783b
commit
1fe7e543ee
48 changed files with 196 additions and 191 deletions
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'goodbye';
|
ipc.config.id = 'goodbye';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.maxRetries= 10;
|
ipc.config.maxRetries= 10;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ ipc.connectToNet(
|
||||||
id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'goodbye'
|
message : 'goodbye'
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.maxRetries=10;
|
ipc.config.maxRetries=10;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ ipc.connectToNet(
|
||||||
id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'hello'
|
message : 'hello'
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,13 +7,13 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
var messages={
|
var messages={
|
||||||
goodbye:false,
|
goodbye:false,
|
||||||
hello:false
|
hello:false
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function(){
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
ipc.connectToNet(
|
ipc.connectToNet(
|
||||||
|
@ -20,7 +20,7 @@ ipc.connectToNet(
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'message',
|
'message',
|
||||||
'hello'
|
'hello'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
@ -38,4 +38,4 @@ ipc.connectToNet(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(ipc)
|
console.log(ipc);
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.maxConnections=1;
|
ipc.config.maxConnections=1;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ ipc.serveNet(
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'socket.disconnected',
|
'socket.disconnected',
|
||||||
function(data,socket){
|
function(data,socket){
|
||||||
console.log(arguments)
|
console.log(arguments);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ ipc.serveNet(
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'error',
|
'error',
|
||||||
function(err){
|
function(err){
|
||||||
ipc.log('Got an ERROR!'.warn,err)
|
ipc.log('Got an ERROR!'.warn,err);
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
|
|
||||||
ipc.server.start();
|
ipc.server.start();
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.sync= true;
|
ipc.config.sync= true;
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ ipc.connectToNet(
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'message',
|
'message',
|
||||||
'hello'+i
|
'hello'+i
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -43,4 +43,4 @@ ipc.connectToNet(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(ipc)
|
console.log(ipc);
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.sync = true;
|
ipc.config.sync = true;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ ipc.serveNet(
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'socket.disconnected',
|
'socket.disconnected',
|
||||||
function(data,socket){
|
function(data,socket){
|
||||||
console.log(arguments)
|
console.log(arguments);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.rawBuffer=true;
|
ipc.config.rawBuffer=true;
|
||||||
ipc.config.encoding='ascii';
|
ipc.config.encoding='ascii';
|
||||||
|
@ -21,7 +21,7 @@ ipc.connectToNet(
|
||||||
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
|
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'hello'
|
'hello'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.rawBuffer=true;
|
ipc.config.rawBuffer=true;
|
||||||
ipc.config.encoding='ascii';
|
ipc.config.encoding='ascii';
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'goodbye';
|
ipc.config.id = 'goodbye';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.maxRetries= 10;
|
ipc.config.maxRetries= 10;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
|
@ -27,7 +27,7 @@ ipc.connectToNet(
|
||||||
id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'goodbye'
|
message : 'goodbye'
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.maxRetries=10;
|
ipc.config.maxRetries=10;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
|
@ -27,7 +27,7 @@ ipc.connectToNet(
|
||||||
id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'hello'
|
message : 'hello'
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,17 +7,17 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||||
}
|
};
|
||||||
|
|
||||||
var messages={
|
var messages={
|
||||||
goodbye:false,
|
goodbye:false,
|
||||||
hello:false
|
hello:false
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function(){
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
rejectUnauthorized:false
|
rejectUnauthorized:false
|
||||||
|
@ -23,7 +23,7 @@ ipc.connectToNet(
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'message',
|
'message',
|
||||||
'hello'
|
'hello'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,12 +7,12 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
//node-ipc will default to its local certs
|
//node-ipc will default to its local certs
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
rejectUnauthorized:false
|
rejectUnauthorized:false
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function(){
|
||||||
|
@ -31,7 +31,7 @@ ipc.serveNet(
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'socket.disconnected',
|
'socket.disconnected',
|
||||||
function(data,socket){
|
function(data,socket){
|
||||||
console.log(arguments)
|
console.log(arguments);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
|
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
|
||||||
|
@ -28,7 +28,7 @@ ipc.connectToNet(
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'message',
|
'message',
|
||||||
'hello'
|
'hello'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||||
|
@ -18,7 +18,7 @@ ipc.config.tls={
|
||||||
trustedConnections: [
|
trustedConnections: [
|
||||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function(){
|
||||||
|
@ -37,7 +37,7 @@ ipc.serveNet(
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'socket.disconnected',
|
'socket.disconnected',
|
||||||
function(data,socket){
|
function(data,socket){
|
||||||
console.log(arguments)
|
console.log(arguments);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.networkHost='localhost';
|
ipc.config.networkHost='localhost';
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
|
@ -29,7 +29,7 @@ ipc.connectToNet(
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'message',
|
'message',
|
||||||
'hello'
|
'hello'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.networkHost='localhost';
|
ipc.config.networkHost='localhost';
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
|
@ -19,7 +19,7 @@ ipc.config.tls={
|
||||||
trustedConnections: [
|
trustedConnections: [
|
||||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function(){
|
||||||
|
@ -38,7 +38,7 @@ ipc.serveNet(
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'socket.disconnected',
|
'socket.disconnected',
|
||||||
function(data,socket){
|
function(data,socket){
|
||||||
console.log(arguments)
|
console.log(arguments);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
rejectUnauthorized:false
|
rejectUnauthorized:false
|
||||||
|
@ -23,7 +23,7 @@ ipc.connectToNet(
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'message',
|
'message',
|
||||||
'hello'
|
'hello'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,12 +7,12 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function(){
|
||||||
|
@ -31,7 +31,7 @@ ipc.serveNet(
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'socket.disconnected',
|
'socket.disconnected',
|
||||||
function(data,socket){
|
function(data,socket){
|
||||||
console.log(arguments)
|
console.log(arguments);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.sync= true;
|
ipc.config.sync= true;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
|
@ -27,7 +27,7 @@ ipc.connectToNet(
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'message',
|
'message',
|
||||||
'hello'+i
|
'hello'+i
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,13 +7,13 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.sync= true;
|
ipc.config.sync= true;
|
||||||
ipc.config.tls={
|
ipc.config.tls={
|
||||||
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
|
||||||
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function(){
|
||||||
|
@ -37,7 +37,7 @@ ipc.serveNet(
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'socket.disconnected',
|
'socket.disconnected',
|
||||||
function(data,socket){
|
function(data,socket){
|
||||||
console.log(arguments)
|
console.log(arguments);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.rawBuffer=true;
|
ipc.config.rawBuffer=true;
|
||||||
ipc.config.encoding='ascii';
|
ipc.config.encoding='ascii';
|
||||||
|
@ -31,7 +31,7 @@ ipc.connectToNet(
|
||||||
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
|
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'hello'
|
'hello'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.rawBuffer=true;
|
ipc.config.rawBuffer=true;
|
||||||
ipc.config.encoding='ascii';
|
ipc.config.encoding='ascii';
|
||||||
|
@ -22,7 +22,7 @@ ipc.config.tls={
|
||||||
trustedConnections: [
|
trustedConnections: [
|
||||||
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
__dirname+'/../../../local-node-ipc-certs/client.pub'
|
||||||
]
|
]
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function(){
|
||||||
|
|
|
@ -15,7 +15,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'goodbye';
|
ipc.config.id = 'goodbye';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
|
@ -45,4 +45,4 @@ ipc.serveNet(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ipc.server.start();
|
ipc.server.start();
|
||||||
|
|
|
@ -15,7 +15,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
|
@ -45,4 +45,4 @@ ipc.serveNet(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ipc.server.start();
|
ipc.server.start();
|
||||||
|
|
|
@ -15,13 +15,13 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
***************************************/
|
***************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
var messages={
|
var messages={
|
||||||
goodbye:false,
|
goodbye:false,
|
||||||
hello:false
|
hello:false
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
'udp4',
|
'udp4',
|
||||||
|
@ -60,4 +60,4 @@ ipc.serveNet(
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ipc.server.start();
|
ipc.server.start();
|
||||||
|
|
|
@ -19,7 +19,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
|
|
|
@ -19,7 +19,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
***************************************/
|
***************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.rawBuffer=true;
|
ipc.config.rawBuffer=true;
|
||||||
ipc.config.encoding='ascii';
|
ipc.config.encoding='ascii';
|
||||||
|
|
|
@ -19,7 +19,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
***************************************/
|
***************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.rawBuffer=true;
|
ipc.config.rawBuffer=true;
|
||||||
ipc.config.encoding='ascii';
|
ipc.config.encoding='ascii';
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'goodbye';
|
ipc.config.id = 'goodbye';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
ipc.connectTo(
|
ipc.connectTo(
|
||||||
|
@ -23,7 +23,7 @@ ipc.connectTo(
|
||||||
id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'goodbye'
|
message : 'goodbye'
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
@ -40,4 +40,4 @@ ipc.connectTo(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
ipc.connectTo(
|
ipc.connectTo(
|
||||||
|
@ -23,7 +23,7 @@ ipc.connectTo(
|
||||||
id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'hello'
|
message : 'hello'
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
@ -46,4 +46,4 @@ ipc.connectTo(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,13 +7,13 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
var messages={
|
var messages={
|
||||||
goodbye:false,
|
goodbye:false,
|
||||||
hello:false
|
hello:false
|
||||||
}
|
};
|
||||||
|
|
||||||
ipc.serve(
|
ipc.serve(
|
||||||
function(){
|
function(){
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry = 1000;
|
ipc.config.retry = 1000;
|
||||||
|
|
||||||
ipc.connectTo(
|
ipc.connectTo(
|
||||||
|
@ -23,7 +23,7 @@ ipc.connectTo(
|
||||||
id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'hello'
|
message : 'hello'
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
ipc.of.world.on(
|
ipc.of.world.on(
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
|
|
||||||
ipc.serve(
|
ipc.serve(
|
||||||
|
|
|
@ -7,9 +7,9 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry = 1000;
|
ipc.config.retry = 1000;
|
||||||
ipc.config.sync= true;
|
ipc.config.sync= true;
|
||||||
|
|
||||||
ipc.connectTo(
|
ipc.connectTo(
|
||||||
'world',
|
'world',
|
||||||
|
@ -27,7 +27,7 @@ ipc.connectTo(
|
||||||
id : ipc.config.id,
|
id : ipc.config.id,
|
||||||
message : 'hello'+i
|
message : 'hello'+i
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,9 +7,9 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.sync= true;
|
ipc.config.sync= true;
|
||||||
|
|
||||||
ipc.serve(
|
ipc.serve(
|
||||||
function(){
|
function(){
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'hello';
|
ipc.config.id = 'hello';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.rawBuffer=true;
|
ipc.config.rawBuffer=true;
|
||||||
ipc.config.encoding='ascii';
|
ipc.config.encoding='ascii';
|
||||||
|
@ -21,7 +21,7 @@ ipc.connectTo(
|
||||||
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
|
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
|
||||||
ipc.of.world.emit(
|
ipc.of.world.emit(
|
||||||
'hello'
|
'hello'
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
|
||||||
*
|
*
|
||||||
* *************************************/
|
* *************************************/
|
||||||
|
|
||||||
ipc.config.id = 'world';
|
ipc.config.id = 'world';
|
||||||
ipc.config.retry= 1500;
|
ipc.config.retry= 1500;
|
||||||
ipc.config.rawBuffer=true;
|
ipc.config.rawBuffer=true;
|
||||||
ipc.config.encoding='ascii';
|
ipc.config.encoding='ascii';
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
var net = require('net'),
|
'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,
|
||||||
|
@ -15,7 +17,8 @@ function init(config,log){
|
||||||
emit : emit,
|
emit : emit,
|
||||||
log : log,
|
log : log,
|
||||||
retriesRemaining:config.maxRetries||0
|
retriesRemaining:config.maxRetries||0
|
||||||
}
|
};
|
||||||
|
|
||||||
new Pubsub(client);
|
new Pubsub(client);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
@ -24,7 +27,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;
|
||||||
|
|
||||||
|
@ -42,7 +45,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);
|
||||||
|
@ -51,7 +54,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);
|
||||||
if(!this.path){
|
if(!this.path){
|
||||||
|
@ -62,7 +65,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;
|
||||||
|
|
||||||
if (process.platform ==='win32' && !client.path.startsWith('\\\\.\\pipe\\')){
|
if (process.platform ==='win32' && !client.path.startsWith('\\\\.\\pipe\\')){
|
||||||
path = path.replace(/^\//, '');
|
path = path.replace(/^\//, '');
|
||||||
|
@ -96,7 +99,7 @@ function connect(){
|
||||||
client.config.tls.trustedConnections=[client.config.tls.trustedConnections];
|
client.config.tls.trustedConnections=[client.config.tls.trustedConnections];
|
||||||
}
|
}
|
||||||
client.config.tls.ca=[];
|
client.config.tls.ca=[];
|
||||||
for(var i=0; i<client.config.tls.trustedConnections.length; i++){
|
for(let i=0; i<client.config.tls.trustedConnections.length; i++){
|
||||||
client.config.tls.ca.push(
|
client.config.tls.ca.push(
|
||||||
fs.readFileSync(client.config.tls.trustedConnections[i])
|
fs.readFileSync(client.config.tls.trustedConnections[i])
|
||||||
);
|
);
|
||||||
|
@ -125,7 +128,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');
|
||||||
|
@ -134,7 +137,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(
|
||||||
|
@ -145,7 +148,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();
|
||||||
|
@ -158,22 +161,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
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -198,8 +198,9 @@ function connect(){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.ipcBuffer)
|
if(!this.ipcBuffer){
|
||||||
this.ipcBuffer='';
|
this.ipcBuffer='';
|
||||||
|
}
|
||||||
|
|
||||||
data=(this.ipcBuffer+=data);
|
data=(this.ipcBuffer+=data);
|
||||||
|
|
||||||
|
@ -210,13 +211,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
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
var Message = require('js-message');
|
'use strict';
|
||||||
|
|
||||||
|
const Message = require('js-message');
|
||||||
|
|
||||||
function formatData(message){
|
function formatData(message){
|
||||||
if(!message.data){
|
if(!message.data){
|
||||||
|
@ -10,18 +12,18 @@ function formatData(message){
|
||||||
|
|
||||||
message=message.JSON+parser.delimiter;
|
message=message.JSON+parser.delimiter;
|
||||||
return message;
|
return message;
|
||||||
};
|
}
|
||||||
|
|
||||||
function parseDataEvents(data){
|
function parseDataEvents(data){
|
||||||
var events=data.split(parser.delimiter);
|
let events=data.split(parser.delimiter);
|
||||||
events.pop();
|
events.pop();
|
||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
var parser={
|
const parser={
|
||||||
parse : parseDataEvents,
|
parse : parseDataEvents,
|
||||||
format : formatData,
|
format : formatData,
|
||||||
delimiter : '\f'
|
delimiter : '\f'
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports=parser;
|
module.exports=parser;
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
var net = require('net'),
|
const net = require('net'),
|
||||||
tls = require('tls'),
|
tls = require('tls'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
dgram = require('dgram'),
|
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;
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ function emit(socket, type, data){
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
};
|
}
|
||||||
|
|
||||||
socket.write(message);
|
socket.write(message);
|
||||||
};
|
}
|
||||||
|
|
||||||
function broadcast(type,data){
|
function broadcast(type,data){
|
||||||
this.log('broadcasting event to all known sockets listening to '.debug, this.path.variable,' : ', ((this.port)?this.port:''), type, data);
|
this.log('broadcasting event to all known sockets listening to '.debug, this.path.variable,' : ', ((this.port)?this.port:''), type, data);
|
||||||
var message=new Message;
|
let message=new Message;
|
||||||
message.type=type;
|
message.type=type;
|
||||||
message.data=data;
|
message.data=data;
|
||||||
|
|
||||||
|
@ -50,18 +50,18 @@ function broadcast(type,data){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.udp4 || this.udp6){
|
if(this.udp4 || this.udp6){
|
||||||
for(var i=1, count=this.sockets.length; i<count; i++){
|
for(let i=1, count=this.sockets.length; i<count; i++){
|
||||||
this.server.write(message,this.sockets[i]);
|
this.server.write(message,this.sockets[i]);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
for(var i=0, count=this.sockets.length; i<count; i++){
|
for(let i=0, count=this.sockets.length; i<count; i++){
|
||||||
this.sockets[i].write(message);
|
this.sockets[i].write(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
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,
|
||||||
|
@ -119,7 +119,7 @@ function init(path,config,log,port){
|
||||||
server.config.tls.trustedConnections=[server.config.tls.trustedConnections];
|
server.config.tls.trustedConnections=[server.config.tls.trustedConnections];
|
||||||
}
|
}
|
||||||
server.config.tls.ca=[];
|
server.config.tls.ca=[];
|
||||||
for(var i=0; i<server.config.tls.trustedConnections.length; i++){
|
for(let i=0; i<server.config.tls.trustedConnections.length; i++){
|
||||||
server.config.tls.ca.push(
|
server.config.tls.ca.push(
|
||||||
fs.readFileSync(server.config.tls.trustedConnections[i])
|
fs.readFileSync(server.config.tls.trustedConnections[i])
|
||||||
);
|
);
|
||||||
|
@ -132,7 +132,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,
|
||||||
|
@ -160,7 +160,7 @@ function init(path,config,log,port){
|
||||||
server.server.on(
|
server.server.on(
|
||||||
'listening',
|
'listening',
|
||||||
function () {
|
function () {
|
||||||
serverCreated(server.server)
|
serverCreated(server.server);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ function init(path,config,log,port){
|
||||||
server.trigger(
|
server.trigger(
|
||||||
'error',
|
'error',
|
||||||
err
|
err
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -208,7 +208,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 : socket);
|
let sock=((server.udp4 || server.udp6)? UDPSocket : socket);
|
||||||
if(server.config.rawBuffer){
|
if(server.config.rawBuffer){
|
||||||
data=new Buffer(data,this.encoding);
|
data=new Buffer(data,this.encoding);
|
||||||
server.trigger(
|
server.trigger(
|
||||||
|
@ -234,7 +234,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);
|
||||||
|
@ -257,7 +257,7 @@ function init(path,config,log,port){
|
||||||
if (!rinfo)
|
if (!rinfo)
|
||||||
return;
|
return;
|
||||||
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;
|
||||||
|
|
||||||
if(server.config.rawSocket){
|
if(server.config.rawSocket){
|
||||||
data=new Buffer(msg,this.encoding);
|
data=new Buffer(msg,this.encoding);
|
||||||
|
@ -279,16 +279,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);
|
||||||
if (process.platform ==='win32'){
|
if (process.platform ==='win32'){
|
||||||
server.path = server.path.replace(/^\//, '');
|
server.path = server.path.replace(/^\//, '');
|
||||||
server.path = server.path.replace(/\//g, '-');
|
server.path = server.path.replace(/\//g, '-');
|
||||||
server.path= '\\\\.\\pipe\\'+server.path;
|
server.path= '\\\\.\\pipe\\'+server.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
server.server.listen(
|
server.server.listen(
|
||||||
server.path,
|
server.path,
|
||||||
|
@ -320,7 +320,7 @@ function init(path,config,log,port){
|
||||||
port : server.port
|
port : server.port
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
)(this)
|
)(this)
|
||||||
);
|
);
|
||||||
|
@ -332,9 +332,9 @@ function init(path,config,log,port){
|
||||||
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;
|
||||||
|
|
||||||
if(socket){
|
if(socket){
|
||||||
if(socket.readable){
|
if(socket.readable){
|
||||||
|
@ -343,7 +343,7 @@ function init(path,config,log,port){
|
||||||
}
|
}
|
||||||
|
|
||||||
if(socket.id){
|
if(socket.id){
|
||||||
destroyedSocketId=socket.id;
|
destroyedSocketId=socket.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
server.log('socket disconnected'.notice,' '+destroyedSocketId.variable);
|
server.log('socket disconnected'.notice,' '+destroyedSocketId.variable);
|
||||||
|
|
46
node-ipc.js
46
node-ipc.js
|
@ -1,10 +1,12 @@
|
||||||
var os = require('os'),
|
'use strict';
|
||||||
dns = require('dns'),
|
|
||||||
util = require('util'),
|
const os = require('os'),
|
||||||
colors = require('colors'),
|
dns = require('dns'),
|
||||||
|
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(
|
||||||
{
|
{
|
||||||
|
@ -18,11 +20,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')? '::1' : '127.0.0.1',
|
networkHost : (IPType=='IPv6')? '::1' : '127.0.0.1',
|
||||||
|
@ -38,9 +40,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,
|
||||||
|
@ -50,16 +52,16 @@ var ipc = {
|
||||||
of : {},
|
of : {},
|
||||||
server : false,
|
server : false,
|
||||||
log : log
|
log : log
|
||||||
}
|
};
|
||||||
|
|
||||||
function log(){
|
function log(){
|
||||||
if(ipc.config.silent){
|
if(ipc.config.silent){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +89,7 @@ function disconnect(id){
|
||||||
}
|
}
|
||||||
|
|
||||||
delete ipc.of[id];
|
delete ipc.of[id];
|
||||||
};
|
}
|
||||||
|
|
||||||
function serve(path,callback){
|
function serve(path,callback){
|
||||||
if(typeof path=='function'){
|
if(typeof path=='function'){
|
||||||
|
@ -232,9 +234,9 @@ function connect(id,path,callback){
|
||||||
ipc.of[id].socket.destroy();
|
ipc.of[id].socket.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
|
@ -302,10 +304,10 @@ function connectNet(id,host,port,callback){
|
||||||
ipc.of[id].socket.destroy();
|
ipc.of[id].socket.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
|
|
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,
|
||||||
|
|
|
@ -19,7 +19,7 @@ describe('TCP Socket verification of client',
|
||||||
ipc.connectToNet(
|
ipc.connectToNet(
|
||||||
'tcpFakeServer',
|
'tcpFakeServer',
|
||||||
8002,
|
8002,
|
||||||
function(){
|
function open(){
|
||||||
ipc.of.tcpFakeServer.on(
|
ipc.of.tcpFakeServer.on(
|
||||||
'error',
|
'error',
|
||||||
function gotError(err){
|
function gotError(err){
|
||||||
|
|
|
@ -6,19 +6,19 @@ describe('TCP Socket verification of server',
|
||||||
function TCPSocketSpec(){
|
function TCPSocketSpec(){
|
||||||
it(
|
it(
|
||||||
'Verify TCP server detects only 1 client out of 2 clients and receives message.',
|
'Verify TCP server detects only 1 client out of 2 clients and receives message.',
|
||||||
function(done){
|
function testIt(done){
|
||||||
ipc.config.id ='testWorld';
|
ipc.config.id ='testWorld';
|
||||||
ipc.config.retry = 1000;
|
ipc.config.retry = 1000;
|
||||||
|
|
||||||
let clientCounter=0;
|
let clientCounter=0;
|
||||||
ipc.config.maxConnections=1;
|
ipc.config.maxConnections=1;
|
||||||
ipc.config.networkPort=8500;
|
ipc.config.networkPort=8500;
|
||||||
|
|
||||||
ipc.serveNet(
|
ipc.serveNet(
|
||||||
function(){
|
function serverStarted(){
|
||||||
ipc.server.on(
|
ipc.server.on(
|
||||||
'connect',
|
'connect',
|
||||||
function(data,socket){
|
function connected(data,socket){
|
||||||
clientCounter++;
|
clientCounter++;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -26,7 +26,7 @@ describe('TCP Socket verification of server',
|
||||||
);
|
);
|
||||||
|
|
||||||
setTimeout(
|
setTimeout(
|
||||||
function(){
|
function timerDelay(){
|
||||||
expect(clientCounter).toBe(ipc.config.maxConnections);
|
expect(clientCounter).toBe(ipc.config.maxConnections);
|
||||||
ipc.server.stop();
|
ipc.server.stop();
|
||||||
done();
|
done();
|
||||||
|
|
Loading…
Reference in a new issue