mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
refactor(socket) rm jsonSend
This commit is contained in:
parent
f205e5913b
commit
926bff1854
1 changed files with 14 additions and 14 deletions
|
|
@ -79,18 +79,18 @@
|
|||
'jsonp-polling'
|
||||
]);
|
||||
|
||||
ret = io.sockets.on('connection', onConnection);
|
||||
ret = io.sockets.on('connection', function(socket) {
|
||||
onConnection(socket, function(json) {
|
||||
var msg = Util.stringifyJSON(json);
|
||||
socket.send(msg);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
};
|
||||
|
||||
function jsonSend(socket, json) {
|
||||
var msg = Util.stringifyJSON(json);
|
||||
socket.send(msg);
|
||||
}
|
||||
|
||||
function onConnection(socket) {
|
||||
function onConnection(socket, callback) {
|
||||
var msg, onDisconect, onMessage;
|
||||
|
||||
++ConNum;
|
||||
|
|
@ -98,14 +98,14 @@
|
|||
if (!Clients[ConNum]) {
|
||||
msg = log(ConNum, 'connected\n');
|
||||
|
||||
jsonSend(socket, {
|
||||
Util.exec(callback, {
|
||||
stdout : msg
|
||||
});
|
||||
|
||||
Clients[ConNum] = true;
|
||||
onMessage = getOnMessage(ConNum, function(json) {
|
||||
jsonSend(socket, json);
|
||||
});
|
||||
|
||||
onMessage = getOnMessage(ConNum, callback);
|
||||
|
||||
onDisconect = Util.retFunc(disconnect, ConNum);
|
||||
|
||||
socket.on('message', onMessage);
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
} else {
|
||||
msg = log(ConNum, ' in use. Reconnecting...\n');
|
||||
|
||||
jsonSend(socket, {
|
||||
Util.exec(callback, {
|
||||
stdout: msg
|
||||
});
|
||||
|
||||
|
|
@ -154,7 +154,7 @@
|
|||
Util.log(connName + pCommand);
|
||||
|
||||
if (equalPart(pCommand, CLOUDCMD))
|
||||
lRet = onCloudCmd(pCommand, Util.retExec(callback, json));
|
||||
lRet = onCloudCmd(pCommand, callback);
|
||||
else if (equalPart(pCommand, 'cd ')) {
|
||||
lRet = true;
|
||||
|
||||
|
|
@ -208,7 +208,7 @@
|
|||
} else if (WIN32 || firstChar === ' ' || isContain)
|
||||
exec(pCommand, options, lExec_func);
|
||||
else
|
||||
getSpawn(pCommand, options, Util.retExec(callback));
|
||||
getSpawn(pCommand, options, callback);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue