Stub of function and command methods

This commit is contained in:
2014-10-31 01:39:14 +01:00
parent 8f594addba
commit ec03419e7d

View File

@@ -12,7 +12,7 @@ function VNBMessageTransform(opts) {
Transform.call(this,opts);
var buffer;
/**
* Transform stream Write implementation
* @param {string} data Upstream data already converted as string
@@ -64,7 +64,7 @@ function VNBMessageTransform(opts) {
* VNB Client implementation (communication from vim to the netbeans server)
* @constructor
* @this {VNBMessageClient}
* @param {net.Socket} socket Incomming stream
* @param {Socket} socket Incomming stream
* @param {authenticationCallback} authentication Callback function called when the AUTH message is received
*/
function VNBClient(socket, authentication) {
@@ -75,6 +75,7 @@ function VNBClient(socket, authentication) {
var self = this;
var callbacks = new Map();
var currentSeqno = 0;
var connected = false;
//TODO check if this is needed
socket.setEncoding("utf8");
@@ -85,6 +86,8 @@ function VNBClient(socket, authentication) {
//The first message must be an authentication one
if (message.startsWith("AUTH ") && authentication(message.substring(message.indexOf(" ") + 1))) {
connected = true;
messageTransform.removeAllListeners("data");
messageTransform.on("data", function(message) {
@@ -213,12 +216,13 @@ function VNBClient(socket, authentication) {
});
}
else {
//TODO send a message to client ?
socket.end();
}
});
messageTransform.on("error", function (error) {
});
messageTransform.on("end",function () {
@@ -229,16 +233,79 @@ function VNBClient(socket, authentication) {
});
self.sendCommand = new function (args...) {
self.sendCommand = function (name, buffer) {
};
self.callFunction = new function (args...) {
self.callFunction = function (name, buffer) {
let seqno = currentSeqno;
currentSeqno += 1;
socket.write()
};
socket.pipe(messageTransform);
}
function NetbeansColor (value) {
"use strict";
this.convert = function() {
return value ? value : "none";
};
}
function NetbeansBool (value) {
"use strict";
this.convert = function () {
return value ? "T" : "F";
};
}
function NetbeansPosition (line, col) {
"use strict";
this.convert = function () {
return line+"/"+col;
};
}
function NetbeansString (value) {
"use strict";
this.convert = function () {
var buffer = "\"";
for (var i = 0 ; i < value.length ; ++i){
switch (value[i]) {
case "\n" :
buffer += "\\n";
break;
case "\t" :
buffer += "\\t";
break;
case "\r" :
buffer += "\\r";
break;
case "\\" :
buffer += "\\\\";
break;
case "\"" :
buffer += "\\\"";
break;
default :
buffer += value[i];
break;
}
}
buffer += "\"";
return buffer;
}
}
VNBClient.prototype = EventEmitter;