udp and TCP support

This commit is contained in:
Brandon Miller 2014-02-27 12:04:30 -08:00
parent 97b745ee4f
commit 46c86f3da2

View file

@ -3,8 +3,7 @@ var os = require('os'),
pubsub = require('event-pubsub'), pubsub = require('event-pubsub'),
eventParser = require('./lib/eventParser.js'), eventParser = require('./lib/eventParser.js'),
Client = require('./lib/client.js'), Client = require('./lib/client.js'),
Server = require('./lib/socketServer.js'), Server = require('./lib/socketServer.js');
socketPrefix= 'app.';
colors.setTheme( colors.setTheme(
{ {
@ -19,8 +18,7 @@ colors.setTheme(
); );
var defaults={ var defaults={
root : process.env.HOME, appspace : 'app.',
appspace : socketPrefix,
socketRoot : '/tmp/', socketRoot : '/tmp/',
networkHost : 'localhost', networkHost : 'localhost',
networkPort : 8000, networkPort : 8000,
@ -201,7 +199,7 @@ function connect(id,path,callback){
callback(); callback();
} }
function connectNet(id,host,port,callback,UDPType){ function connectNet(id,host,port,callback){
if(!id){ if(!id){
ipc.log( ipc.log(
'Service id required'.warn, 'Service id required'.warn,
@ -210,23 +208,15 @@ function connectNet(id,host,port,callback,UDPType){
return; return;
} }
if(typeof host=='number'){ if(typeof host=='number'){
UDPType=callback;
callback=port; callback=port;
port=host; port=host;
host=false; host=false;
} }
if(typeof host=='function'){ if(typeof host=='function'){
UDPType=port;
callback=host; callback=host;
host=false; host=false;
port=false; port=false;
} }
if(host=='udp4' || host=='udp6'){
UDPType=host;
host=false;
port=false;
callback=false;
}
if(!host){ if(!host){
ipc.log( ipc.log(
'Server host not specified, so defaulting to'.notice, 'Server host not specified, so defaulting to'.notice,
@ -237,15 +227,9 @@ function connectNet(id,host,port,callback,UDPType){
} }
if(typeof port=='function'){ if(typeof port=='function'){
UDPType=callback;
callback=port; callback=port;
port=false; port=false;
} }
if(typeof port == 'string'){
UDPType=port;
port=false;
callback=false;
}
if(!port){ if(!port){
ipc.log( ipc.log(
'Server port not specified, so defaulting to'.notice, 'Server port not specified, so defaulting to'.notice,