mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(terminal) init
This commit is contained in:
parent
e9c594cce0
commit
2173f203f1
1 changed files with 3 additions and 16 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue