node-ipc/example/TCPSocket/basic/world-server.js

45 lines
918 B
JavaScript
Raw Normal View History

2014-02-22 20:13:31 +11:00
var ipc=require('../../../node-ipc');
/***************************************\
2015-12-10 21:29:15 +11:00
*
2014-02-22 20:13:31 +11:00
* You should start both hello and world
* then you will see them communicating.
2015-12-10 21:29:15 +11:00
*
2014-02-22 20:13:31 +11:00
* *************************************/
ipc.config.id = 'world';
ipc.config.retry= 1500;
ipc.config.maxConnections=1;
2014-02-22 20:13:31 +11:00
2014-02-27 09:04:09 +11:00
ipc.serveNet(
2014-02-22 20:13:31 +11:00
function(){
ipc.server.on(
'message',
function(data,socket){
ipc.log('got a message : '.debug, data);
ipc.server.emit(
socket,
2014-02-22 20:13:31 +11:00
'message',
data+' world!'
);
}
);
2015-12-10 21:29:15 +11:00
ipc.server.on(
'socket.disconnected',
function(data,socket){
console.log(arguments)
}
);
2014-02-22 20:13:31 +11:00
}
);
ipc.server.on(
'error',
function(err){
ipc.log('Got an ERROR!'.warn,err)
}
)
2015-12-10 21:29:15 +11:00
ipc.server.start();