node-ipc/spec/support/jasmineTest/udp4Server.js

54 lines
1,017 B
JavaScript
Raw Normal View History

2016-01-10 01:03:05 -08:00
'use strict';
2016-01-09 23:23:40 -08:00
const ipc=require('../../../node-ipc');
const process=require('process');
2016-09-30 06:00:28 -07:00
const dieAfter=60000;
2015-12-04 18:40:38 -08:00
2016-01-09 23:23:40 -08:00
//die after 60 seconds
setTimeout(
function killServerProcess(){
process.exit(0);
},
dieAfter
);
2015-12-04 18:40:38 -08:00
2016-01-09 23:23:40 -08:00
ipc.config.id = 'udpServer';
2015-12-04 18:40:38 -08:00
ipc.config.retry= 1500;
2016-01-09 23:23:40 -08:00
ipc.config.silent=true;
2016-01-10 02:39:14 -08:00
ipc.config.networkPort=8095;
2015-12-04 18:40:38 -08:00
ipc.serveNet(
'udp4',
2016-01-09 23:23:40 -08:00
function serverStarted(){
2016-09-30 06:00:28 -07:00
console.log(`
UP
`);
2015-12-04 18:40:38 -08:00
ipc.server.on(
'message',
2016-01-09 23:23:40 -08:00
function gotMessage(data,socket){
2016-09-30 06:00:28 -07:00
console.log(`
MESSAGE
`);
ipc.server.emit(
2015-12-04 18:40:38 -08:00
socket,
'message',
{
id : ipc.config.id,
message : 'I am UDP4 server!'
2015-12-04 18:40:38 -08:00
}
);
}
);
}
);
ipc.server.start();