First Commit of new way of building the Platform
This commit is contained in:
1 parent
e48cf0dae5
commit
40e60b42cc
4616 files changed
+713402
No files matched your search
+35
@@ -0,0 +1,35 @@
|
||||
const ipc=require('../../../node-ipc');
|
||||
|
||||
/***************************************\
|
||||
*
|
||||
* You should start both hello and world
|
||||
* then you will see them communicating.
|
||||
*
|
||||
* *************************************/
|
||||
|
||||
ipc.config.id = 'hello';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.rawBuffer=true;
|
||||
ipc.config.encoding='ascii';
|
||||
|
||||
ipc.serveNet(
|
||||
8001, //we set the port here because the world server is already using the default of 8000. So we can not bind to 8000 while world is using it.
|
||||
'udp4',
|
||||
function(){
|
||||
ipc.server.on(
|
||||
'data',
|
||||
function(data){
|
||||
ipc.log('got a message from world ', data, data.toString());
|
||||
}
|
||||
);
|
||||
ipc.server.emit(
|
||||
{
|
||||
address : 'localhost',
|
||||
port : ipc.config.networkPort
|
||||
},
|
||||
'hello'
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.start();
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
const ipc=require('../../../node-ipc');
|
||||
|
||||
/***************************************\
|
||||
*
|
||||
* UDP Client is really a UDP server
|
||||
*
|
||||
* Dedicated UDP sockets on the same
|
||||
* machine can not be bound to in the
|
||||
* traditional client/server method
|
||||
*
|
||||
* Every UDP socket is it's own UDP server
|
||||
* And so must have a unique port on its
|
||||
* machine, unlike TCP or Unix Sockts
|
||||
* which can share on the same machine.
|
||||
*
|
||||
* Since there is no open client server
|
||||
* relationship, you should start world
|
||||
* first and then hello.
|
||||
*
|
||||
***************************************/
|
||||
|
||||
ipc.config.id = 'world';
|
||||
ipc.config.retry= 1500;
|
||||
ipc.config.rawBuffer=true;
|
||||
ipc.config.encoding='ascii';
|
||||
|
||||
ipc.serveNet(
|
||||
'udp4',
|
||||
function(){
|
||||
ipc.server.on(
|
||||
'data',
|
||||
function(data,socket){
|
||||
ipc.log('got a message', data,data.toString());
|
||||
ipc.server.emit(
|
||||
socket,
|
||||
'goodbye'
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
ipc.server.start();
|
||||
Reference in new issue
Block a user