node-ipc/spec/support/jasmineTest/TCP/tcpSocketServer.spec.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

2016-01-10 20:03:05 +11:00
'use strict';
const ipc = require('../../../../node-ipc');
2016-01-10 18:23:40 +11:00
ipc.config.id ='testWorld';
ipc.config.retry = 1000;
describe('TCP Socket verification of server',
function(){
2016-01-10 20:03:05 +11:00
2016-01-10 18:23:40 +11:00
it(
'Verify TCP server detects only 1 client out of 2 clients and receives message.',
function(done){
2016-01-10 20:03:05 +11:00
let clientCounter =0;
ipc.config.maxConnections=1;
ipc.config.networkPort=8500;
2016-01-10 20:03:05 +11:00
ipc.serveNet(
function(){
ipc.server.on(
'app.message',
function(data,socket){
2016-01-10 20:03:05 +11:00
clientCounter++;
2016-01-10 20:03:05 +11:00
expect(data.id).toBe('tcpClient');
expect(data.message).toBe('I am TCP client.');
2016-01-10 20:03:05 +11:00
}
);
2016-01-10 20:03:05 +11:00
setTimeout(
function(){
expect(clientCounter).toBe(1);
2016-01-10 20:03:05 +11:00
done();
},2000
);
}
);
2016-01-10 20:03:05 +11:00
ipc.server.start();
2016-01-10 20:03:05 +11:00
}
);
2016-01-10 18:23:40 +11:00
}
);