|
@@ -975,10 +975,31 @@ void CIOCPModel::_CaptureProc(PER_IO_CONTEXT* pIoContext, ProPackage* pak)
|
|
|
|
|
|
void CIOCPModel::_TestWizardProc(PER_IO_CONTEXT* pIoContext, ProPackage* pak)
|
|
|
{
|
|
|
- if (TW::SendKey) {
|
|
|
- std::string key = (char*)&pak->buf;
|
|
|
- TW::SendKey(key.c_str());
|
|
|
+ char* retdata = "0"; //0表示失败,1表示成功
|
|
|
+ //content: ir>keyname 或者 cmd>cmd命令
|
|
|
+ std::string content = (char*)&pak->buf;
|
|
|
+ std::int8_t idx = content.find(">");
|
|
|
+ if (idx == string::npos) return;
|
|
|
+ std::string type = content.substr(0,idx);
|
|
|
+ std::string cmd = content.substr(idx + 1, content.size());
|
|
|
+ LPCTSTR twCmd = cmd.c_str();
|
|
|
+ OutputDebugString(_T("_TestWizardProc\n"));
|
|
|
+ if ((TW::sendCmd) && (type == "cmd")) {
|
|
|
+ boolean retFlag = TW::sendCmd(twCmd);
|
|
|
+ if (retFlag == true) retdata = "1";
|
|
|
+ else retdata = "0";
|
|
|
+ }else if ((TW::SendKey) && (type == "ir")) {
|
|
|
+ boolean retFlag = TW::SendKey(twCmd);
|
|
|
+ if (retFlag == true) retdata = "1";
|
|
|
+ else retdata = "0";
|
|
|
}
|
|
|
+ byte* sdata = new byte[strlen(retdata) + PAK_LEN];
|
|
|
+ ProPackage* reponse_pak = (ProPackage*)sdata;
|
|
|
+ reponse_pak->header.version = 0xAC;
|
|
|
+ reponse_pak->header.len = strlen(retdata) + PAK_LEN;
|
|
|
+ memcpy(reponse_pak->buf, retdata, strlen(retdata));
|
|
|
+ int ret = send(pIoContext->m_sockAccept, (const char*)sdata, reponse_pak->header.len, 0);
|
|
|
+ TRACE1("ret= %d\n",ret);
|
|
|
}
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|