From b24a38206739ea16e893c8c41aa098533d573e5c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 26 Jun 2013 07:39:24 -0400 Subject: [PATCH] fix(socket) isContainStr -> isContainStrAtBegin --- lib/server/socket.js | 88 ++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 5f61ca19..6c24e0ca 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -55,55 +55,55 @@ */ function onMessage(pConnNum, pSocket){ return function(pCommand) { - Util.log(pCommand); + Util.log(pCommand); + + if( Util.isContainStrAtBegin(pCommand, 'cloudcmd') ){ + pCommand = Util.removeStr(pCommand, 'cloudcmd'); - if( Util.isContainStr(pCommand, 'cloudcmd') ){ - pCommand = Util.removeStr(pCommand, 'cloudcmd'); + if( Util.isContainStrAtBegin(pCommand, ' ') ){ + pCommand = Util.removeStr(pCommand, ' '); - if( Util.isContainStr(pCommand, ' ') ){ - pCommand = Util.removeStr(pCommand, ' '); - - if( Util.isContainStr(pCommand, 'update') && update ) - update.get(); - - if( Util.strCmp(pCommand, 'exit') ) - if(main.WIN32) - pCommand = 'taskkill -f /PID ' + process.pid; - else - pCommand = 'kill -9 ' + process.pid; - } - else { - var lMsg = { - stdout : 'cloudcmd exit - for shutdown cloudcmd', - stderr : null - }; - - lMsg = JSON.stringify(lMsg); - pSocket.send(lMsg); - - Util.log('received from client: ' + pCommand); - Util.log('sended to client: ' + lMsg); - } - } - - /* if we on windows and command is build in - * change code page to unicode becouse - * windows use unicode on non English versions - */ - if(Win32_b){ - var lWinCommand = pCommand.toUpperCase(); + if( Util.isContainStrAtBegin(pCommand, 'update') && update ) + update.get(); - if( Win32Commands.indexOf(lWinCommand) > 0 ) - pCommand = 'chcp 65001 |' + pCommand; + if( Util.strCmp(pCommand, 'exit') ) + if(main.WIN32) + pCommand = 'taskkill -f /PID ' + process.pid; + else + pCommand = 'kill -9 ' + process.pid; } + else { + var lMsg = { + stdout : 'cloudcmd exit - for shutdown cloudcmd', + stderr : null + }; + + lMsg = JSON.stringify(lMsg); + pSocket.send(lMsg); + + Util.log('received from client: ' + pCommand); + Util.log('sended to client: ' + lMsg); + } + } + + /* if we on windows and command is build in + * change code page to unicode becouse + * windows use unicode on non English versions + */ + if(Win32_b){ + var lWinCommand = pCommand.toUpperCase(); - if(!ClientFuncs[pConnNum]) - ClientFuncs[pConnNum] = getExec(pSocket); - - var lExec_func = ClientFuncs[pConnNum]; - - exec(pCommand, lExec_func); - }; + if( Win32Commands.indexOf(lWinCommand) > 0 ) + pCommand = 'chcp 65001 |' + pCommand; + } + + if(!ClientFuncs[pConnNum]) + ClientFuncs[pConnNum] = getExec(pSocket); + + var lExec_func = ClientFuncs[pConnNum]; + + exec(pCommand, lExec_func); + }; }