|
|
@@ -13,6 +13,8 @@ using namespace FreeRDPWrap;
|
|
|
#include <mutex>
|
|
|
#include <thread>
|
|
|
#include "path.h"
|
|
|
+#include <boost/process.hpp>
|
|
|
+#include <boost/thread.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -139,28 +141,37 @@ std::pair<ErrorCodeEnum, int> CModTools::StartChromiumBrowser(){
|
|
|
|
|
|
}
|
|
|
|
|
|
-std::pair<ErrorCodeEnum, int> CModTools::openCef(std::string cmdline)
|
|
|
+void CModTools::cefClientGuardian(std::string cmdline)
|
|
|
{
|
|
|
-#if (defined _WIN32 || defined _WIN64)
|
|
|
- DbgEx("Eventually invoke FreeRDPWrap! tid: %d", std::this_thread::get_id());
|
|
|
- auto pClient = new FreeRDPWrapSrv_ClientBase(this->m_pEntity);
|
|
|
- auto rc = pClient->Connect();
|
|
|
- if (Error_Succeed != rc)
|
|
|
- DbgEx("connect to FreeRDPWrapSrv entity fail: %d", rc);
|
|
|
-
|
|
|
- FreeRDPWrapSrv_CreateProcessRunAs_Req req = {};
|
|
|
- FreeRDPWrapSrv_CreateProcessRunAs_Ans ans = {};
|
|
|
- req.strCmdLine = cmdline.c_str();
|
|
|
- rc = pClient->CreateProcessRunAs(req, ans, 10000);
|
|
|
- if (rc != Error_Succeed)
|
|
|
- DbgEx("get CreateProcessRunAs fail from FreeRDPWrap: %d", rc);
|
|
|
- else
|
|
|
+ while (true)
|
|
|
{
|
|
|
- DbgEx("get CreateProcessRunAs succeed from FreeRDPWrap: %d, pid:%d", rc, ans.retCode);
|
|
|
- return std::make_pair(Error_Succeed, ans.retCode);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ boost::process::child child_process(cmdline);
|
|
|
+ DbgEx("open cefclient pid:%d, cmd:%s", child_process.id(), cmdline.c_str());
|
|
|
+ child_process.wait();
|
|
|
+ }
|
|
|
+ catch (const std::exception& e)
|
|
|
+ {
|
|
|
+ std::cout << e.what() << std::endl;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ catch (...)
|
|
|
+ {
|
|
|
+ int i = 10;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
|
}
|
|
|
- return std::make_pair(rc, 0);
|
|
|
-#endif
|
|
|
+ return;
|
|
|
+}
|
|
|
+
|
|
|
+std::pair<ErrorCodeEnum, int> CModTools::openCef(std::string cmdline)
|
|
|
+{
|
|
|
+ //mod_chromiumÏ൱ÓÚcefclientµÄÊØ»¤½ø³Ì
|
|
|
+ static std::string guardianStr = cmdline;
|
|
|
+ boost::thread cefGuardian(boost::bind(&CModTools::cefClientGuardian, this, guardianStr));
|
|
|
+ cefGuardian.detach();
|
|
|
return std::make_pair(Error_Succeed, 0);
|
|
|
}
|
|
|
|