2014-09-06 13:30:48 +10:00
|
|
|
var ipc=require('../../../node-ipc');
|
2014-09-06 12:34:51 +10:00
|
|
|
|
|
|
|
ipc.config.id = __dirname.split('/');
|
|
|
|
ipc.config.id = ipc.config.id[ipc.config.id.length-1]
|
|
|
|
ipc.config.maxRetries=1;
|
|
|
|
|
2014-09-06 13:30:48 +10:00
|
|
|
expectedClient=ipc.config.id+'-client';
|
|
|
|
|
2014-09-06 12:34:51 +10:00
|
|
|
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',
|
2014-09-06 13:30:48 +10:00
|
|
|
test+' : detected wrong id of '+socket.id+' expecting :: '+expectedClient
|
2014-09-06 12:34:51 +10:00
|
|
|
);
|
|
|
|
}
|
|
|
|
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'
|
|
|
|
);
|
|
|
|
|
2014-09-06 13:30:48 +10:00
|
|
|
var test='tcp-client-registered with proper id'
|
|
|
|
|
2014-09-06 12:34:51 +10:00
|
|
|
if(socket.id==expectedClient){
|
|
|
|
ipc.of.testHarness.emit(
|
|
|
|
'pass',
|
2014-09-06 13:30:48 +10:00
|
|
|
test
|
2014-09-06 12:34:51 +10:00
|
|
|
);
|
2014-09-06 13:30:48 +10:00
|
|
|
}else{
|
|
|
|
ipc.of.testHarness.emit(
|
|
|
|
'fail',
|
|
|
|
test+' : detected wrong id of '+id+' expecting :: '+expectedClient
|
|
|
|
);
|
2014-09-06 12:34:51 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
ipc.server.define.listen.message='This event type listens for message strings as value of data key.';
|
|
|
|
|
|
|
|
ipc.server.start();
|