mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
fixed bug of multiple call of sockets
This commit is contained in:
parent
a40c19bc8c
commit
abe7644a1d
2 changed files with 11 additions and 12 deletions
|
|
@ -21,6 +21,8 @@ and get them out to file system.
|
|||
|
||||
* Added ability to degradate to http from https.
|
||||
|
||||
* Fixed bug of multiple call of sockets.
|
||||
|
||||
|
||||
2012.03.01, Version 0.1.9
|
||||
|
||||
|
|
|
|||
|
|
@ -22,16 +22,15 @@
|
|||
exports.listen = function(pServer){
|
||||
var lRet;
|
||||
if(io){
|
||||
io = io.listen(pServer);
|
||||
var lListen = io.listen(pServer),
|
||||
/* number of connections */
|
||||
lConnNum = 0;
|
||||
|
||||
/* number of connections */
|
||||
var lConnNum = 0;
|
||||
|
||||
lRet = io.sockets.on('connection', function (socket){
|
||||
lRet = lListen.sockets.on('connection', function (socket){
|
||||
++lConnNum;
|
||||
socket.send('{"stdout":"client connected"}');
|
||||
|
||||
console.log('server connected');
|
||||
Util.log('server connected');
|
||||
|
||||
if(!OnMessageFuncs[lConnNum])
|
||||
OnMessageFuncs[lConnNum] = onMessage(lConnNum, socket);
|
||||
|
|
@ -54,7 +53,7 @@
|
|||
*/
|
||||
function onMessage(pConnNum, pSocket){
|
||||
return function(pCommand) {
|
||||
console.log(pCommand);
|
||||
Util.log(pCommand);
|
||||
|
||||
if( Util.isContainStr(pCommand, 'cloudcmd') ){
|
||||
pCommand = Util.removeStr(pCommand, 'cloudcmd');
|
||||
|
|
@ -80,10 +79,8 @@
|
|||
lMsg = JSON.stringify(lMsg);
|
||||
pSocket.send(lMsg);
|
||||
|
||||
console.log('received from client: ' + pCommand);
|
||||
console.log('sended to client: ' + lMsg);
|
||||
|
||||
return;
|
||||
Util.log('received from client: ' + pCommand);
|
||||
Util.log('sended to client: ' + lMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +111,7 @@
|
|||
function getExec(pSocket){
|
||||
return function(pError, pStdout, pStderr) {
|
||||
if (pError !== null) {
|
||||
console.log('exec error: ' + pError);
|
||||
Util.log('exec error: ' + pError);
|
||||
}
|
||||
|
||||
var lExec = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue