This commit is contained in:
Brandon Nozaki Miller 2016-01-10 04:18:14 -08:00
parent 97d1e0783b
commit 1fe7e543ee
48 changed files with 196 additions and 191 deletions

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'goodbye';
ipc.config.id = 'goodbye';
ipc.config.retry= 1500;
ipc.config.maxRetries= 10;
@ -24,7 +24,7 @@ ipc.connectToNet(
id : ipc.config.id,
message : 'goodbye'
}
)
);
}
);
ipc.of.world.on(

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.maxRetries=10;
@ -24,7 +24,7 @@ ipc.connectToNet(
id : ipc.config.id,
message : 'hello'
}
)
);
}
);
ipc.of.world.on(

View file

@ -7,13 +7,13 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
var messages={
goodbye:false,
hello:false
}
};
ipc.serveNet(
function(){

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.connectToNet(
@ -20,7 +20,7 @@ ipc.connectToNet(
ipc.of.world.emit(
'message',
'hello'
)
);
}
);
ipc.of.world.on(
@ -38,4 +38,4 @@ ipc.connectToNet(
}
);
console.log(ipc)
console.log(ipc);

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.maxConnections=1;
@ -28,7 +28,7 @@ ipc.serveNet(
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
console.log(arguments);
}
);
}
@ -37,8 +37,8 @@ ipc.serveNet(
ipc.server.on(
'error',
function(err){
ipc.log('Got an ERROR!'.warn,err)
ipc.log('Got an ERROR!'.warn,err);
}
)
);
ipc.server.start();

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.sync= true;
@ -24,7 +24,7 @@ ipc.connectToNet(
ipc.of.world.emit(
'message',
'hello'+i
)
);
}
}
);
@ -43,4 +43,4 @@ ipc.connectToNet(
}
);
console.log(ipc)
console.log(ipc);

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.sync = true;
@ -34,7 +34,7 @@ ipc.serveNet(
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
console.log(arguments);
}
);
}

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.rawBuffer=true;
ipc.config.encoding='ascii';
@ -21,7 +21,7 @@ ipc.connectToNet(
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
ipc.of.world.emit(
'hello'
)
);
}
);

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.rawBuffer=true;
ipc.config.encoding='ascii';

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'goodbye';
ipc.config.id = 'goodbye';
ipc.config.retry= 1500;
ipc.config.maxRetries= 10;
ipc.config.tls={
@ -27,7 +27,7 @@ ipc.connectToNet(
id : ipc.config.id,
message : 'goodbye'
}
)
);
}
);
ipc.of.world.on(

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.maxRetries=10;
ipc.config.tls={
@ -27,7 +27,7 @@ ipc.connectToNet(
id : ipc.config.id,
message : 'hello'
}
)
);
}
);
ipc.of.world.on(

View file

@ -7,17 +7,17 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.tls={
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
}
};
var messages={
goodbye:false,
hello:false
}
};
ipc.serveNet(
function(){

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.tls={
rejectUnauthorized:false
@ -23,7 +23,7 @@ ipc.connectToNet(
ipc.of.world.emit(
'message',
'hello'
)
);
}
);
ipc.of.world.on(

View file

@ -7,12 +7,12 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
//node-ipc will default to its local certs
ipc.config.tls={
rejectUnauthorized:false
}
};
ipc.serveNet(
function(){
@ -31,7 +31,7 @@ ipc.serveNet(
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
console.log(arguments);
}
);
}

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.tls={
private: __dirname+'/../../../local-node-ipc-certs/private/client.key',
@ -28,7 +28,7 @@ ipc.connectToNet(
ipc.of.world.emit(
'message',
'hello'
)
);
}
);
ipc.of.world.on(

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.tls={
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
@ -18,7 +18,7 @@ ipc.config.tls={
trustedConnections: [
__dirname+'/../../../local-node-ipc-certs/client.pub'
]
}
};
ipc.serveNet(
function(){
@ -37,7 +37,7 @@ ipc.serveNet(
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
console.log(arguments);
}
);
}

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.networkHost='localhost';
ipc.config.tls={
@ -29,7 +29,7 @@ ipc.connectToNet(
ipc.of.world.emit(
'message',
'hello'
)
);
}
);
ipc.of.world.on(

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.networkHost='localhost';
ipc.config.tls={
@ -19,7 +19,7 @@ ipc.config.tls={
trustedConnections: [
__dirname+'/../../../local-node-ipc-certs/client.pub'
]
}
};
ipc.serveNet(
function(){
@ -38,7 +38,7 @@ ipc.serveNet(
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
console.log(arguments);
}
);
}

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.tls={
rejectUnauthorized:false
@ -23,7 +23,7 @@ ipc.connectToNet(
ipc.of.world.emit(
'message',
'hello'
)
);
}
);
ipc.of.world.on(

View file

@ -7,12 +7,12 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.tls={
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
}
};
ipc.serveNet(
function(){
@ -31,7 +31,7 @@ ipc.serveNet(
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
console.log(arguments);
}
);
}

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.sync= true;
ipc.config.tls={
@ -27,7 +27,7 @@ ipc.connectToNet(
ipc.of.world.emit(
'message',
'hello'+i
)
);
}
}
);

View file

@ -7,13 +7,13 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.sync= true;
ipc.config.tls={
public: __dirname+'/../../../local-node-ipc-certs/server.pub',
private: __dirname+'/../../../local-node-ipc-certs/private/server.key'
}
};
ipc.serveNet(
function(){
@ -37,7 +37,7 @@ ipc.serveNet(
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
console.log(arguments);
}
);
}

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.rawBuffer=true;
ipc.config.encoding='ascii';
@ -31,7 +31,7 @@ ipc.connectToNet(
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
ipc.of.world.emit(
'hello'
)
);
}
);

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.rawBuffer=true;
ipc.config.encoding='ascii';
@ -22,7 +22,7 @@ ipc.config.tls={
trustedConnections: [
__dirname+'/../../../local-node-ipc-certs/client.pub'
]
}
};
ipc.serveNet(
function(){

View file

@ -15,7 +15,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'goodbye';
ipc.config.id = 'goodbye';
ipc.config.retry= 1500;
ipc.serveNet(

View file

@ -15,7 +15,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.serveNet(

View file

@ -15,13 +15,13 @@ var ipc=require('../../../node-ipc');
*
***************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
var messages={
goodbye:false,
hello:false
}
};
ipc.serveNet(
'udp4',

View file

@ -19,7 +19,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.serveNet(

View file

@ -19,7 +19,7 @@ var ipc=require('../../../node-ipc');
*
***************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.serveNet(

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.rawBuffer=true;
ipc.config.encoding='ascii';

View file

@ -19,7 +19,7 @@ var ipc=require('../../../node-ipc');
*
***************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.rawBuffer=true;
ipc.config.encoding='ascii';

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'goodbye';
ipc.config.id = 'goodbye';
ipc.config.retry= 1500;
ipc.connectTo(
@ -23,7 +23,7 @@ ipc.connectTo(
id : ipc.config.id,
message : 'goodbye'
}
)
);
}
);
ipc.of.world.on(

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.connectTo(
@ -23,7 +23,7 @@ ipc.connectTo(
id : ipc.config.id,
message : 'hello'
}
)
);
}
);
ipc.of.world.on(

View file

@ -7,13 +7,13 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
var messages={
goodbye:false,
hello:false
}
};
ipc.serve(
function(){

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry = 1000;
ipc.connectTo(
@ -23,7 +23,7 @@ ipc.connectTo(
id : ipc.config.id,
message : 'hello'
}
)
);
}
);
ipc.of.world.on(

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.serve(

View file

@ -7,9 +7,9 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry = 1000;
ipc.config.sync= true;
ipc.config.sync= true;
ipc.connectTo(
'world',
@ -27,7 +27,7 @@ ipc.connectTo(
id : ipc.config.id,
message : 'hello'+i
}
)
);
}
}
);

View file

@ -7,9 +7,9 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.sync= true;
ipc.config.sync= true;
ipc.serve(
function(){

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'hello';
ipc.config.id = 'hello';
ipc.config.retry= 1500;
ipc.config.rawBuffer=true;
ipc.config.encoding='ascii';
@ -21,7 +21,7 @@ ipc.connectTo(
ipc.log('## connected to world ##'.rainbow, ipc.config.delay);
ipc.of.world.emit(
'hello'
)
);
}
);

View file

@ -7,7 +7,7 @@ var ipc=require('../../../node-ipc');
*
* *************************************/
ipc.config.id = 'world';
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.rawBuffer=true;
ipc.config.encoding='ascii';

View file

@ -1,13 +1,15 @@
var net = require('net'),
tls = require('tls'),
'use strict';
const net = require('net'),
tls = require('tls'),
eventParser = require('../lib/eventParser.js'),
Pubsub = require('event-pubsub'),
Message = require('js-message'),
fs = require('fs'),
Queue = require('js-queue');
Pubsub = require('event-pubsub'),
Message = require('js-message'),
fs = require('fs'),
Queue = require('js-queue');
function init(config,log){
var client={
let client={
config : config,
queue : new Queue,
socket : false,
@ -15,7 +17,8 @@ function init(config,log){
emit : emit,
log : log,
retriesRemaining:config.maxRetries||0
}
};
new Pubsub(client);
return client;
@ -24,7 +27,7 @@ function init(config,log){
function emit(type,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.data=data;
@ -42,7 +45,7 @@ function emit(type,data){
this.queue.add(
syncEmit.bind(this,message)
);
};
}
function syncEmit(message){
this.log('dispatching event to '.debug, this.id.variable, this.path.variable,' : ', message.data);
@ -51,7 +54,7 @@ function syncEmit(message){
function connect(){
//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);
if(!this.path){
@ -62,7 +65,7 @@ function connect(){
if(!client.port){
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\\')){
path = path.replace(/^\//, '');
@ -96,7 +99,7 @@ function connect(){
client.config.tls.trustedConnections=[client.config.tls.trustedConnections];
}
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(
fs.readFileSync(client.config.tls.trustedConnections[i])
);
@ -125,7 +128,7 @@ function connect(){
client.socket.on(
'connect',
function(){
function connectionMade(){
client.trigger('connect');
client.retriesRemaining=client.config.maxRetries;
client.log('retrying reset');
@ -134,7 +137,7 @@ function connect(){
client.socket.on(
'close',
function(){
function connectionClosed(){
client.log('connection closed'.notice ,client.id.variable , client.path.variable, client.retriesRemaining+' tries remaining of '+client.config.maxRetries);
if(
@ -145,7 +148,7 @@ function connect(){
client.log(
client.config.id.variable,
'exceeded connection rety amount of'.warn,
" or stopRetrying flag set."
' or stopRetrying flag set.'
);
client.socket.destroy();
@ -158,22 +161,19 @@ function connect(){
client.isRetrying=true;
setTimeout(
(
function(client){
return function(){
client.retriesRemaining--;
client.isRetrying=false;
client.connect();
setTimeout(
function(){
if(!client.isRetrying)
client.retriesRemaining=client.config.maxRetries;
},
100
)
}
}
)(client),
function retryTimeout(){
client.retriesRemaining--;
client.isRetrying=false;
client.connect();
setTimeout(
function resetRetriesCheck(){
if(!client.isRetrying){
client.retriesRemaining=client.config.maxRetries;
}
},
100
);
}.bind(null,client),
client.config.retry
);
@ -198,8 +198,9 @@ function connect(){
return;
}
if(!this.ipcBuffer)
if(!this.ipcBuffer){
this.ipcBuffer='';
}
data=(this.ipcBuffer+=data);
@ -210,13 +211,13 @@ function connect(){
this.ipcBuffer='';
var events = eventParser.parse(data);
var eCount = events.length;
for(var i=0; i<eCount; i++){
var message=new Message;
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 of type '.debug, message.type.data, message.data);
client.log('detected event of type '.debug, message.type.data, message.data);
client.trigger(
message.type,
message.data

View file

@ -1,4 +1,6 @@
var Message = require('js-message');
'use strict';
const Message = require('js-message');
function formatData(message){
if(!message.data){
@ -10,18 +12,18 @@ function formatData(message){
message=message.JSON+parser.delimiter;
return message;
};
}
function parseDataEvents(data){
var events=data.split(parser.delimiter);
let events=data.split(parser.delimiter);
events.pop();
return events;
}
var parser={
const parser={
parse : parseDataEvents,
format : formatData,
delimiter : '\f'
}
};
module.exports=parser;

View file

@ -1,15 +1,15 @@
var net = require('net'),
tls = require('tls'),
fs = require('fs'),
dgram = require('dgram'),
const net = require('net'),
tls = require('tls'),
fs = require('fs'),
dgram = require('dgram'),
eventParser = require('../lib/eventParser.js'),
Pubsub = require('event-pubsub'),
Pubsub = require('event-pubsub'),
Message = require('js-message');
function emit(socket, type, data){
this.log('dispatching event to socket'.debug, ' : ', type.data, data);
var message=new Message;
let message=new Message;
message.type=type;
message.data=data;
@ -32,14 +32,14 @@ function emit(socket, type, data){
socket
);
return;
};
}
socket.write(message);
};
}
function broadcast(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;
this.log('broadcasting event to all known sockets listening to '.debug, this.path.variable,' : ', ((this.port)?this.port:''), type, data);
let message=new Message;
message.type=type;
message.data=data;
@ -50,18 +50,18 @@ function broadcast(type,data){
}
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]);
}
}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);
}
}
};
}
function init(path,config,log,port){
var server={
let server={
config : config,
path : path,
port : port,
@ -119,7 +119,7 @@ function init(path,config,log,port){
server.config.tls.trustedConnections=[server.config.tls.trustedConnections];
}
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(
fs.readFileSync(server.config.tls.trustedConnections[i])
);
@ -132,7 +132,7 @@ function init(path,config,log,port){
}
}else{
function UDPWrite(message,socket){
var data=new Buffer(message, server.config.encoding);
let data=new Buffer(message, server.config.encoding);
server.server.send(
data,
0,
@ -160,7 +160,7 @@ function init(path,config,log,port){
server.server.on(
'listening',
function () {
serverCreated(server.server)
serverCreated(server.server);
}
);
}
@ -173,7 +173,7 @@ function init(path,config,log,port){
server.trigger(
'error',
err
)
);
}
);
@ -208,7 +208,7 @@ function init(path,config,log,port){
socket.on(
'data',
function(data,UDPSocket){
var sock=((server.udp4 || server.udp6)? UDPSocket : socket);
let sock=((server.udp4 || server.udp6)? UDPSocket : socket);
if(server.config.rawBuffer){
data=new Buffer(data,this.encoding);
server.trigger(
@ -234,7 +234,7 @@ function init(path,config,log,port){
data=eventParser.parse(data);
while(data.length>0){
var message=new Message;
let message=new Message;
message.load(data.shift());
server.log('received event of : '.debug,message.type.data,message.data);
@ -257,7 +257,7 @@ function init(path,config,log,port){
if (!rinfo)
return;
server.log('Received UDP message from '.debug, rinfo.address.variable, rinfo.port);
var data;
let data;
if(server.config.rawSocket){
data=new Buffer(msg,this.encoding);
@ -279,16 +279,16 @@ function init(path,config,log,port){
}
function started(socket){
server.onStart(socket)
server.onStart(socket);
}
if(!port){
server.log('starting server as'.debug, 'Unix || Windows Socket'.variable);
if (process.platform ==='win32'){
server.path = server.path.replace(/^\//, '');
server.path = server.path.replace(/\//g, '-');
server.path= '\\\\.\\pipe\\'+server.path;
}
server.path = server.path.replace(/^\//, '');
server.path = server.path.replace(/\//g, '-');
server.path= '\\\\.\\pipe\\'+server.path;
}
server.server.listen(
server.path,
@ -320,7 +320,7 @@ function init(path,config,log,port){
port : server.port
}
);
}
};
}
)(this)
);
@ -332,9 +332,9 @@ function init(path,config,log,port){
server.on(
'close',
function(){
for(var i=0, count=server.sockets.length; i<count; i++){
var socket=server.sockets[i];
var destroyedSocketId=false;
for(let i=0, count=server.sockets.length; i<count; i++){
let socket=server.sockets[i];
let destroyedSocketId=false;
if(socket){
if(socket.readable){
@ -343,7 +343,7 @@ function init(path,config,log,port){
}
if(socket.id){
destroyedSocketId=socket.id;
destroyedSocketId=socket.id;
}
server.log('socket disconnected'.notice,' '+destroyedSocketId.variable);

View file

@ -1,10 +1,12 @@
var os = require('os'),
dns = require('dns'),
util = require('util'),
colors = require('colors'),
'use strict';
const os = require('os'),
dns = require('dns'),
util = require('util'),
colors = require('colors'),
eventParser = require('./lib/eventParser.js'),
Client = require('./lib/client.js'),
Server = require('./lib/socketServer.js');
Client = require('./lib/client.js'),
Server = require('./lib/socketServer.js');
colors.setTheme(
{
@ -18,11 +20,11 @@ colors.setTheme(
}
);
var IPType=os.networkInterfaces()[
const IPType=os.networkInterfaces()[
Object.keys(os.networkInterfaces())[0]
][0].family
][0].family;
var defaults={
let defaults={
appspace : 'app.',
socketRoot : '/tmp/',
networkHost : (IPType=='IPv6')? '::1' : '127.0.0.1',
@ -38,9 +40,9 @@ var defaults={
stopRetrying : false,
IPType : IPType,
tls : false
}
};
var ipc = {
let ipc = {
config : defaults,
connectTo : connect,
connectToNet: connectNet,
@ -50,16 +52,16 @@ var ipc = {
of : {},
server : false,
log : log
}
};
function log(){
if(ipc.config.silent){
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'){
continue;
}
@ -87,7 +89,7 @@ function disconnect(id){
}
delete ipc.of[id];
};
}
function serve(path,callback){
if(typeof path=='function'){
@ -232,9 +234,9 @@ function connect(id,path,callback){
ipc.of[id].socket.destroy();
}
ipc.of[id] = new Client(ipc.config,ipc.log);
ipc.of[id].id = id;
ipc.of[id].path = path;
ipc.of[id] = new Client(ipc.config,ipc.log);
ipc.of[id].id = id;
ipc.of[id].path = path;
ipc.of[id].connect();
@ -302,10 +304,10 @@ function connectNet(id,host,port,callback){
ipc.of[id].socket.destroy();
}
ipc.of[id] = new Client(ipc.config,ipc.log);
ipc.of[id].id = id;
ipc.of[id].path = host;
ipc.of[id].port = port;
ipc.of[id] = new Client(ipc.config,ipc.log);
ipc.of[id].id = id;
ipc.of[id].path = host;
ipc.of[id].port = port;
ipc.of[id].connect();

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
var addSorting = (function () {
"use strict";
'use strict';
var cols,
currentSort = {
index: 0,

View file

@ -19,7 +19,7 @@ describe('TCP Socket verification of client',
ipc.connectToNet(
'tcpFakeServer',
8002,
function(){
function open(){
ipc.of.tcpFakeServer.on(
'error',
function gotError(err){

View file

@ -6,7 +6,7 @@ describe('TCP Socket verification of server',
function TCPSocketSpec(){
it(
'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.retry = 1000;
@ -15,10 +15,10 @@ describe('TCP Socket verification of server',
ipc.config.networkPort=8500;
ipc.serveNet(
function(){
function serverStarted(){
ipc.server.on(
'connect',
function(data,socket){
function connected(data,socket){
clientCounter++;
}
);
@ -26,7 +26,7 @@ describe('TCP Socket verification of server',
);
setTimeout(
function(){
function timerDelay(){
expect(clientCounter).toBe(ipc.config.maxConnections);
ipc.server.stop();
done();