diff --git a/ChangeLog b/ChangeLog index 2a9142ec..de709f38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/lib/server/socket.js b/lib/server/socket.js index f064a044..0a63de2a 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -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 = {