|
|
@ -25,6 +25,11 @@ var cmdsrv = function(options){ |
|
|
this.caseSensitive = options["caseSensitive"] || false; |
|
|
this.caseSensitive = options["caseSensitive"] || false; |
|
|
this.delimiter = options["delimiter"] || " "; |
|
|
this.delimiter = options["delimiter"] || " "; |
|
|
|
|
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
this.tokenize = options["tokenizer"] || function(line){ |
|
|
|
|
|
return line.split(self.delimiter); |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
var self = this; |
|
|
var self = this; |
|
|
this.server = net.createServer(function(connection){ |
|
|
this.server = net.createServer(function(connection){ |
|
|
self.handle(connection); |
|
|
self.handle(connection); |
|
|
@ -41,7 +46,7 @@ cmdsrv.prototype.handle = function(connection){ |
|
|
connection.on("line", function(line){ |
|
|
connection.on("line", function(line){ |
|
|
line = line.trim(); |
|
|
line = line.trim(); |
|
|
self.emit("line", connection, line) |
|
|
self.emit("line", connection, line) |
|
|
var parts = line.split(self.delimiter); |
|
|
|
|
|
|
|
|
var parts = self.tokenize(line); |
|
|
|
|
|
|
|
|
if(!parts.length){ |
|
|
if(!parts.length){ |
|
|
return; |
|
|
return; |
|
|
|