fix(socket) isContainStr -> isContainStrAtBegin

This commit is contained in:
coderaiser 2013-06-26 07:39:24 -04:00
parent 40c8e6118b
commit b24a382067

View file

@ -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);
};
}