constdaemon=require('fxNetSocket').daemon;varproc=newdaemon('file.js',[args],{env:env});// start child process proc.init();// by send message proc.send(message[,sendHandle[,options]][,callback])// by restart// import call need 1.0 sec rebootproc.restart();// close the IPC channel call eventproc.stop();// command lie kill proc proc.quiet();
FxTCP example
consttcp=newrequire('fxNetSocket').fxTCP();constoptions={'host': '0.0.0.0','port': 80,'closeWaitTime':5000,// Setting close_wait timeout'backlog': 511}tcp.createServer(options);tcp.on('onRead',function(nread,buffer,handle){// Client to use the request Connections.// handle.mode// handle.wsProtocol// handle.namespace});
FxWebSocketClient example
constwsClient=require('fxNetSocket').WSClient;varoption={"binaryType":"arraybuffer"};varws=newwsClient(socket,connectHandler);functionconnectHandler(){// connectionws.on('data',function(data){//console.log('Data Event is received ws-packet Stream.');});ws.on('message',function(msg){//console.log('Message is decode ws-packet Stream on:', msg);});}functionsend(json){ws.write(json);}