refactor(terminal) init

This commit is contained in:
coderaiser 2014-06-06 05:57:37 -04:00
parent e9c594cce0
commit 2173f203f1

View file

@ -14,35 +14,22 @@
CHANNEL = CloudFunc.CHANNEL_TERMINAL,
CHANNEL_RESIZE = CloudFunc.CHANNEL_TERMINAL_RESIZE,
ConNum = 0,
INFO = 'to use terminal install pty.js: npm i pty.js';
ConNum = 0;
/**
* function listen on servers port
* @pServer {Object} started server object
*/
exports.init = function() {
var ret, func,
makePty = function(clientSocket) {
var makePty = function(clientSocket) {
onConnection(clientSocket, function(channel, data) {
socket.emit(channel, data, clientSocket);
});
},
sendInfo = function(clientSocket) {
Util.log(INFO);
socket.emit(CHANNEL, INFO, clientSocket);
};
if (pty)
func = makePty;
else
func = sendInfo;
socket.on('connection', makePty);
ret = socket.on('connection', func);
return ret;
};
function onConnection(clientSocket, callback) {