Эх сурвалжийг харах

Z991239-360 #comment fea 上传Linux迁移修改

陈良瑜80374463 5 жил өмнө
parent
commit
8610170119

+ 2 - 2
CMakeSettings.json

@@ -22,7 +22,7 @@
       "buildCommandArgs": "",
       "ctestCommandArgs": "--output-on-failure",
       "inheritEnvironments": [ "linux_x64" ],
-      "remoteMachineName": "-1872074873;99.12.23.77 (username=leizm, port=22, authentication=Password)",
+      "remoteMachineName": "-1315925427;99.12.22.125 (username=pcacc, port=22, authentication=Password)",
       "remoteCMakeListsRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/src",
       "remoteBuildRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/out/build/${name}",
       "remoteInstallRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/out/install/${name}",
@@ -61,7 +61,7 @@
       "buildCommandArgs": "",
       "ctestCommandArgs": "--output-on-failure",
       "inheritEnvironments": [ "linux_x64" ],
-      "remoteMachineName": "-1872074873;99.12.23.77 (username=leizm, port=22, authentication=Password)",
+      "remoteMachineName": "-1315925427;99.12.22.125 (username=pcacc, port=22, authentication=Password)",
       "remoteCMakeListsRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/src",
       "remoteBuildRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/out/build/${name}",
       "remoteInstallRoot": "$HOME/.vs/${projectDirName}/${workspaceHash}/out/install/${name}",

+ 2 - 1
Module/mod_chromium/BufferOperation.h

@@ -374,12 +374,13 @@ static inline void WriteT(char *iobuf, T &t, int* wpos, int* capacity)
 {
 	buffer_write(iobuf, IOBUF_T_BUF, &t, sizeof(t), wpos, capacity);
 }
-
+/*
 template<class T>
 static inline void WriteT(char *iobuf, const T &t)
 {
 	buffer_write(iobuf, IOBUF_T_BUF, &t, sizeof(t), wpos, capacity);
 }
+	*/
 
 
 template<class T>

+ 142 - 0
Module/mod_chromium/CMakeLists.txt

@@ -0,0 +1,142 @@
+#实体命名
+define_module("Chromium")
+
+
+
+#整个实体加载的文件
+if(WIN32)
+set(${MODULE_PREFIX}_SRCS
+	baseEx.cpp
+	baseEx.h
+	BufferOperation.h
+	Chromium_client_g.h
+	Chromium_def_g.h
+	Chromium_msg_g.h
+	Chromium_server_g.h
+	ChromiumFSM.cpp
+	ChromiumFSM.h
+	CMessage.cpp
+	CMessage.h
+	CMethodInterface.h
+	CMethodParam.h
+	CModTools.cpp
+	CModTools.h
+	CSocketClient.cpp
+	CSocketClient.h
+	CStructureInterpreter.cpp
+	CStructureInterpreter.h
+	CTransStruct.h
+	CWebsocketServer.cpp
+	CWebsocketServer.h
+	CWSCodec.cpp
+	CWSCodec.h
+	EntitySessionManager.cpp
+	EntitySessionManager.h
+	ISocketCallback.h
+	Job.h
+	MessageType.h
+	mod_chromium.cpp
+	mod_chromium.h
+	processControl.cpp
+	processControl.h
+	portCheck/portCheck.h
+	portCheck/portCheck.cpp
+	${ThirdPartyHeadRoot}/CJson/cJson.c
+	${ThirdPartyHeadRoot}/modp_b64/modp_b64.cc
+	${ThirdPartyHeadRoot}/tinyxml2/tinyxml2.cpp
+	)
+else()
+set(${MODULE_PREFIX}_SRCS
+	baseEx.cpp
+	baseEx.h
+	BufferOperation.h
+	Chromium_client_g.h
+	Chromium_def_g.h
+	Chromium_msg_g.h
+	Chromium_server_g.h
+	ChromiumFSM.cpp
+	ChromiumFSM.h
+	CMessage.cpp
+	CMessage.h
+	CMethodInterface.h
+	CMethodParam.h
+	CModTools.cpp
+	CModTools.h
+	CSocketClient.cpp
+	CSocketClient.h
+	CStructureInterpreter.cpp
+	CStructureInterpreter.h
+	CTransStruct.h
+	CWebsocketServer.cpp
+	CWebsocketServer.h
+	CWSCodec.cpp
+	CWSCodec.h
+	EntitySessionManager.cpp
+	EntitySessionManager.h
+	ISocketCallback.h
+	MessageType.h
+	mod_chromium.cpp
+	mod_chromium.h
+	processControl.cpp
+	processControl.h
+	)
+endif(WIN32)
+
+#设置版本
+set(MOD_VERSION_STRING "1.0.0-dev1")
+add_module_libraries(${MODULE_PREFIX} ${MODULE_NAME} ${MOD_VERSION_STRING})
+#附加包含的目录
+
+
+conan_cmake_run(boost/1.69.0@LR04.02_ThirdParty/testing
+BASIC_SETUP CMAKE_TARGETS
+BUILD missing)
+
+set(BOOST_ROOT ${CONAN_DIRS_BOOST})
+set(Boost_DEBUG ON)
+set(Boost_USE_STATIC_LIBS   ON)
+if (OS_WINDOWS)
+else()
+	set(Boost_NO_SYSTEM_PATHS ON)
+	set(Boost_USE_MULTITHREADED      ON)
+	set(Boost_USE_STATIC_RUNTIME    ON)
+	add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
+endif()
+
+
+
+find_package(Boost COMPONENTS atomic chrono date_time filesystem regex system thread REQUIRED)
+
+if(Boost_FOUND)
+	include_directories(${Boost_INCLUDE_DIRS})
+
+	MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}")
+	MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}")
+	MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}")
+
+endif()
+
+
+
+target_include_directories(${MODULE_NAME} PRIVATE
+	${RVC_FRAMEWORK_INCLUDES_DIR}
+	${CONAN_INCLUDE_DIRS_OPENSSL}
+	${ThirdPartyHeadRoot}/websocketpp
+	${ThirdPartyHeadRoot}/tinyxml2
+	${ThirdPartyHeadRoot}/CJson
+	${ThirdPartyHeadRoot}/modp_b64
+	${CONAN_RVCFRAMEWORK_ROOT}/include
+)
+# 添加实体需要依赖的其他共享库(包括系统库):连接器包含的包
+target_link_directories(${MODULE_NAME} PRIVATE
+	${CONAN_LIB_DIRS_BOOST} ${CONAN_LIB_DIRS_OPENSSL}
+)
+set(${MODULE_PREFIX}_LIBS ${MODULE_BASE_ALL_LIBS} ${CONAN_PKG_LIBS_OPENSSL} ${Boost_LIBRARIES})
+
+
+target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})  
+
+deploy_module(${MODULE_PREFIX} ${MODULE_NAME})
+
+# 设置要依赖拷贝的第三方库
+set(MODULE_CONAN_DEP_LIBS ${MODULE_CONAN_DEP_LIBS} ${CONAN_BIN_DIRS} ${CONAN_LIB_DIRS} PARENT_SCOPE)

+ 37 - 2
Module/mod_chromium/CMessage.cpp

@@ -1,12 +1,35 @@
+#if (defined _WIN32 || defined _WIN64)
 #include <stdafx.h>
+#endif
+
 #include "CMessage.h"
 #include <memory.h>
 #include <string>
+#include <locale>
+#if !(defined _WIN32 || defined _WIN64)
+int memcpy_s(void* det, size_t detSize, const void* src, size_t srcSize)
+{
+	uint8_t errorcode = 0;
+	if (srcSize > detSize || src == NULL || det == NULL)
+	{
+		if (srcSize > detSize)
+			errorcode = 1;
+		else if (src == NULL)
+			errorcode = 2;
+		else if (det == NULL)
+			errorcode = 3;
+		fflush(stdout);
+		return -1;
+	}
+	else
+		memcpy(det, src, srcSize);
 
-
+	return 1;
+}
+#endif
 
 namespace Chromium{
-
+#if (defined _WIN32 || defined _WIN64)
 	std::string UtfToGbk(const char* utf8)
 	{
 		int len = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
@@ -37,6 +60,17 @@ namespace Chromium{
 		delete[] wszUtf8;
 		return ret;
 	}
+#else
+	std::string UtfToGbk(const char* utf8)
+	{
+		return utf8;
+	}
+	std::string ConvertGBKToUtf8(std::string& strGBK)
+	{
+		return strGBK;
+	}
+#endif
+
 
 CMessage::CMessage():
 	_buf_length(SUGGEST_BUFFER_LENGTH){
@@ -88,6 +122,7 @@ int CMessage::memoryDynamicGrowth(){
 		return -1;
 	}
 	int err = memcpy_s(p, this->_buf_length*2, this->_data, this->_buf_length);
+
 	if (0 != err)
 	{
 		delete[] p;

+ 2 - 0
Module/mod_chromium/CMessage.h

@@ -1,5 +1,7 @@
 #ifndef CMessage__h
 #define CMessage__h
+#include <string>
+#include <iostream>
 
 #define MAX_TRANSFER_LEN	(1024*1024)
 

+ 18 - 5
Module/mod_chromium/CModTools.cpp

@@ -1,19 +1,24 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
+#include "../mod_FreeRDPWrap/FreeRDPWrap_client_g.h"
+using namespace FreeRDPWrap;
+#endif
 #include "baseEx.h"
 #include "CModTools.h"
 #include "SpIni.h"
 #include <vector>
-#include "../mod_FreeRDPWrap/FreeRDPWrap_client_g.h"
+
 #include <memory>
 #include <iostream>
+#include <mutex>
 
 
-using namespace FreeRDPWrap;
 
 extern std::pair<bool, std::string> DetectActiveHttp(std::vector<std::string> urlArr);
 namespace Chromium{
 
-CRITICAL_SECTION g_csInvokFreeRDP;
+//CRITICAL_SECTION g_csInvokFreeRDP;
+	std::mutex g_mutexFreerdp;
 
 CModTools::CModTools(CEntityBase* pEntity){
 	this->m_pEntity = pEntity;
@@ -22,6 +27,7 @@ CModTools::CModTools(CEntityBase* pEntity){
 
 bool CModTools::killAllChromium()
 {
+#if (defined _WIN32 || defined _WIN64)
 	auto pClient = new FreeRDPWrapSrv_ClientBase(this->m_pEntity);
 	auto rc = pClient->Connect();
 	if (Error_Succeed != rc)
@@ -38,12 +44,16 @@ bool CModTools::killAllChromium()
 		return rc == Error_Succeed;
 	}
 	return true;
+#else
+	return true;
+#endif
 }
 
 std::pair<ErrorCodeEnum, int> CModTools::StartChromiumBrowser(){
-	EnterCriticalSection(&g_csInvokFreeRDP);
+#if (defined _WIN32 || defined _WIN64)
+	g_mutexFreerdp.lock();
 	std::shared_ptr<void> delHandleFun((void*)0, [&](void*) {
-		LeaveCriticalSection(&g_csInvokFreeRDP);
+		g_mutexFreerdp.unlock();
 	});
 	DbgEx("Pre invoke FreeRDPWrap... tid: %d", GetCurrentThreadId());
 	
@@ -127,6 +137,9 @@ std::pair<ErrorCodeEnum, int> CModTools::StartChromiumBrowser(){
 	DbgEx("Leave StartChromiumBrowser tid: %d", GetCurrentThreadId());
 	
 	return std::make_pair(Error_Unexpect, 0);
+#else
+	return std::make_pair(Error_Unexpect, 0);
+#endif
 }
 
 void CModTools::RestartProxyServer(){

+ 2 - 1
Module/mod_chromium/CModTools.h

@@ -3,10 +3,11 @@
 
 #define CHROMIUM_TIMER_ID 0xF001
 #include <tuple>
+#include <mutex>
 
 namespace Chromium{
 
-extern CRITICAL_SECTION g_csInvokFreeRDP;
+//extern CRITICAL_SECTION g_csInvokFreeRDP;
 	
 class CModTools{
 private:

+ 12 - 19
Module/mod_chromium/CSocketClient.cpp

@@ -1,4 +1,6 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
+#endif
 
 #define __STDC_LIMIT_MACROS 1
 #include "CSocketClient.h"
@@ -8,6 +10,7 @@
 #include <vector>
 #include <string>
 #include "portCheck/portCheck.h"
+#include <thread>
 
 using boost::asio::ip::tcp;
 
@@ -22,7 +25,7 @@ std::pair<bool, std::string> DetectActiveHttp(std::vector<std::string> urlArr)
 {
 	std::vector<boost::shared_future<bool>> threadArr;
 
-	for each (const auto it in urlArr)
+	for (const auto it : urlArr)
 		threadArr.push_back(boost::async(boost::bind(checkHttpThreadFun, it)));
 
 	boost::this_thread::sleep_for(boost::chrono::seconds(1));
@@ -65,7 +68,8 @@ namespace Chromium{
 	
 
 
-CSocketClient::CSocketClient(CEntityBase* pEntity, unsigned int id):m_vbuf(128),m_psocket(NULL),m_pNetThread(NULL),mID(id)
+CSocketClient::CSocketClient(CEntityBase* pEntity, unsigned int id)
+	:m_vbuf(128),m_pNetThread(nullptr),mID(id)
 {
 	m_pEntity = pEntity;
 }
@@ -73,12 +77,11 @@ CSocketClient::CSocketClient(CEntityBase* pEntity, unsigned int id):m_vbuf(128),
 CSocketClient::CSocketClient(boost::asio::io_service &ios, const char* ipAddr, 
 	const char* port, CEntityBase* pEntity, unsigned int id):
 	m_ep(boost::asio::ip::address_v4::from_string(ipAddr), atoi(port)),
-	m_pio(&ios),
 	m_buf(100, 0),
+	m_pNetThread(nullptr),
 	m_vbuf(128),
-	m_pNetThread(NULL),
-	m_pEntity(pEntity),
-	mID(id)
+	mID(id),
+	m_pEntity(pEntity)
 {
 	::DbgEx("CSocketClient constructor ip=%s, port=%s", ipAddr, port);
 	m_psocket = sock_ptr (new socket_type(ios));
@@ -89,9 +92,8 @@ CSocketClient::~CSocketClient(){
 }
 
 ErrorCodeEnum CSocketClient::Connect(){
-	long id = GetCurrentThreadId();
 	boost::system::error_code ec;
-	DbgEx("CSocketClient method -> connect thread_id = %ld, object=%ld", id, this);
+	DbgEx("CSocketClient method -> connect thread_id = %ld, object=%ld", std::this_thread::get_id(), this);
 	m_psocket->connect(m_ep, ec);
 	if (ec)
 	{
@@ -132,7 +134,6 @@ ErrorCodeEnum CSocketClient::Write(CMessage *pMsg){
 }
 
 ErrorCodeEnum CSocketClient::StartSocketService(){
-//	boost::thread thread1(boost::bind(&CSocketClient::thread_recv, this));
 	if (NULL == m_pNetThread)
 	{
 		m_pNetThread = new boost::thread(boost::bind(&CSocketClient::thread_recv, this));
@@ -154,8 +155,7 @@ ErrorCodeEnum CSocketClient::StopSocketService(){
 }
 
 void CSocketClient::handle_connect(const boost::system::error_code& err){
-	long id = GetCurrentThreadId();
-	DbgEx("CSocketClient method -> handle_connect thread_id = %ld, object=%ld", id, this);
+	DbgEx("CSocketClient method -> handle_connect thread_id = %ld, object=%ld", std::this_thread::get_id(), this);
 	if (err)
 	{
 		// connect failed!
@@ -174,20 +174,13 @@ void CSocketClient::handle_connect(const boost::system::error_code& err){
 
 void CSocketClient::handle_close(const boost::system::error_code& err){
 	DbgEx("CSocketClient method -> handle_close : %s", err.message().c_str());
-// 	DbgEx("CSocketClient method try reconnect");
-// /*	m_pio->post(boost::bind(&this_type::do_close, this));*/
-// 	// ÓÀÔ¶±£³ÖÁ¬½Ó
-// 	while(Error_Succeed != this->Connect()){
-// 		Sleep(100);
-// 	}
 	return;
 }
 
 ErrorCodeEnum CSocketClient::Reconnect()
 {
-	long id = GetCurrentThreadId();
 	boost::system::error_code ec;
-	DbgEx("CSocketClient method -> reconnect thread_id = %ld, object=%ld", id, this);
+	DbgEx("CSocketClient method -> reconnect thread_id = %ld, object=%ld", std::this_thread::get_id(), this);
 	CModTools modTools(this->m_pEntity);
 	modTools.RestartProxyServer();
 	m_psocket->connect(m_ep, ec);

+ 3 - 2
Module/mod_chromium/CSocketClient.h

@@ -4,6 +4,7 @@
 #include "ErrorCode.h"
 #include <deque>
 #include <boost/bind.hpp>
+#include "boost/bind.hpp"
 #include <boost/asio.hpp>
 #include <boost/function.hpp>
 #include <boost/thread.hpp>
@@ -11,6 +12,7 @@
 #include "ISocketCallback.h"
 #include <vector>
 #include "baseEx.h"
+#include <iostream>
 
 //extern class CWebsocketServer;
 
@@ -38,7 +40,6 @@ public:
 	ErrorCodeEnum Write(CMessage *pMsg);
 	ErrorCodeEnum StartSocketService();
 	ErrorCodeEnum StopSocketService();
-
 	ErrorCodeEnum SetMessageHandler(ISocketCallback *obj);
 
 private:
@@ -57,7 +58,7 @@ private:
 	endpoint_type m_ep;
 	sock_ptr m_psocket;
 	buffer_type m_buf;
-	boost::asio::io_service *m_pio;
+
 	boost::thread* m_pNetThread;
 	unsigned int mID;
 

+ 6 - 28
Module/mod_chromium/CStructureInterpreter.cpp

@@ -1,8 +1,12 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
-#include "CStructureInterpreter.h"
 #include <io.h>
+#endif
+#include "CStructureInterpreter.h"
+
 #include <fstream>
 #include <strstream>
+#include <baseEx.h>
 
 namespace Chromium{
 
@@ -14,42 +18,16 @@ CStructureInterpreter::CStructureInterpreter(const char* path)
 };
 
 void CStructureInterpreter::getAllFiles(){
-	long   hFile   =   0;  
-	//ÎļþÐÅÏ¢  
-	struct _finddata_t fileinfo;
-	std::string p;
-	if((hFile = _findfirst(p.assign(this->mPathOfXmls).append("\\*").c_str(),&fileinfo)) !=  -1)
-	{  
-		do  
-		{
-			if((fileinfo.attrib &  _A_SUBDIR))  
-			{  
-				if(strcmp(fileinfo.name,".") != 0  &&  strcmp(fileinfo.name,"..") != 0)  
-				{
-					mFiles.push_back(p.assign(this->mPathOfXmls).append("\\").append(fileinfo.name) );
-				}
-			}  
-			else  
-			{  
-				mFiles.push_back(p.assign(this->mPathOfXmls).append("\\").append(fileinfo.name) );  
-			} 
-
-		}while(_findnext(hFile, &fileinfo)  == 0);  
-
-		_findclose(hFile); 
-	} 
+	mFiles = find_files(this->mPathOfXmls, "*.xml");
 }
 
 void CStructureInterpreter::loadXmlFiles(){
-	//DbgEx("CStructureInterpreter loadXmlFiles");
 	this->getAllFiles();
-	//DbgEx("CStructureInterpreter loadXmlFiles file num = %d", this->mFiles.size());
 	int i = 0;
 	for (i=0;i<this->mFiles.size();++i)
 	{
 		tinyxml2::XMLDocument doc;
 		doc.LoadFile( this->mFiles.at(i).c_str() );
-
 		if( tinyxml2::XML_SUCCESS == doc.ErrorID()){
 			this->parseXmlToMap(doc);
 		}

+ 29 - 13
Module/mod_chromium/CWSCodec.cpp

@@ -1,4 +1,6 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
+#endif
 #include "BufferOperation.h"
 #include "modp_b64.h"
 #include "SpHelper.h"
@@ -75,9 +77,9 @@ void CWSCodec::DeserializeBase(CMessage& msg, CTransStruct& ts, int& rpos, cJSON
 	std::string t_arr[] = { "messageType", "sessionID", "transID", "isEnd", "errorCode", "errorMsg" };
 	std::vector<std::string> c_repeatParamList(t_arr, t_arr + sizeof(t_arr) / sizeof(t_arr[0]));
 
-	for each (auto paramInfo in ts.mParamList)
+	for (auto paramInfo : ts.mParamList)
 	{
-		for each (auto repeatName in c_repeatParamList)
+		for (auto repeatName : c_repeatParamList)
 		{
 			if (paramInfo.mName == repeatName)
 				DbgEx("requestAck参数名字重复, error, %s", paramInfo.mName);
@@ -90,7 +92,7 @@ void CWSCodec::DeserializeBase(CMessage& msg, CTransStruct& ts, int& rpos, cJSON
 		while (i != ts.mParamList.end())
 		{
 			bool t_isRepeat = false;
-			for each (auto repeatName in c_repeatParamList)
+			for (auto repeatName : c_repeatParamList)
 			{
 				if (i->mName == repeatName)
 				{
@@ -263,10 +265,10 @@ void CWSCodec::DeserializeRequestAck(CMessage& msg, std::map<int, entity_def_str
 	{
 		DbgEx("error DeserializeRequestAck: %s, %s, %s", p_struct->entity_name, p_struct->class_name, p_struct->methodID);
 		std::string errorMsg;
-		for each(auto it in ts.mParamList)
+		for(auto it : ts.mParamList)
 			errorMsg += it.mName + "--" + it.mType + "_";
 		DbgEx(errorMsg.c_str());
-		throw std::exception("error DeserializeRequestAck");
+		throw std::exception(std::logic_error("error DeserializeRequestAck"));
 	}
 }
 
@@ -291,10 +293,10 @@ void CWSCodec::DeserializeEvent(CMessage& msg,
 	catch (...)
 	{
 		std::string errorMsg;
-		for each(auto it in ts.mParamList)
+		for(auto it : ts.mParamList)
 			errorMsg += it.mName + "--" + it.mType + "_";
 		DbgEx(errorMsg.c_str());
-		throw std::exception("error DeserializeRequestAck");
+		throw std::exception(std::logic_error("error DeserializeRequestAck"));
 	}
 }
 
@@ -686,9 +688,9 @@ void CWSCodec::SerializeRequest(cJSON* js, char* data, int* wpos, int* capacity,
 		//detect the same name 
 		std::string t_arr[] = { "transID", "sessionID", "methodID", "signature", "timeout" ,"messageType","class","entity","methodID" };
 		std::vector<std::string> c_repeatParamList(t_arr, t_arr + sizeof(t_arr) / sizeof(t_arr[0]));
-		for each (auto paramInfo in pI->mRequestInterpreter.mParamList)
+		for (auto paramInfo : pI->mRequestInterpreter.mParamList)
 		{
-			for each (auto repeatName in c_repeatParamList)
+			for (auto repeatName : c_repeatParamList)
 			{
 				if (paramInfo.mName == repeatName)
 					DbgEx("request参数名字重复, error, %s", paramInfo.mName);
@@ -994,12 +996,16 @@ bool CWSCodec::GetCJsonObjectValue(cJSON *root, const char* strKey, CSimpleStrin
 	bool ret = false;
 	pTmpNode = cJSON_GetObjectItem(root, strKey);
 	if(NULL != pTmpNode){
+#if (defined(_WIN32) || defined(_WIN64))
 		CSimpleStringW wStr = "";
 		UTF8ToUnicode(pTmpNode->valuestring, wStr);
 		//DbgEx("GetCJsonObjectValue string : %s", pTmpNode->valuestring);
 		//hexdump(pTmpNode->valuestring, strlen(pTmpNode->valuestring));
 		dstValue = CSimpleStringW2A(wStr);
 //		dstValue = pTmpNode->valuestring;
+#else
+		dstValue = pTmpNode->valuestring;
+#endif
 		ret = true;
 	}else{
 		strcat(errmsg, strKey);
@@ -1014,7 +1020,11 @@ bool CWSCodec::GetCJsonObjectValue(cJSON *root, const char* strKey, CSimpleStrin
 	bool ret = false;
 	pTmpNode = cJSON_GetObjectItem(root, strKey);
 	if(NULL != pTmpNode){
+#if (defined(_WIN32) || defined(_WIN64))
 		UTF8ToUnicode(pTmpNode->valuestring, dstValue);
+#else
+		dstValue = pTmpNode->valuestring;
+#endif
 //		dstValue = pTmpNode->valuestring;
 		ret = true;
 	}else{
@@ -1155,12 +1165,15 @@ bool CWSCodec::GetCJsonObjectValue(cJSON *obj, unsigned int& dstValue,    char*
 
 bool CWSCodec::GetCJsonObjectValue(cJSON *obj, CSimpleStringA& dstValue, char* errmsg){
 	if(cJSON_String == obj->type){
-//		dstValue = obj->valuestring;
 		DbgEx("GetCJsonObjectValue CSimpleStringA = %s", obj->valuestring);
 		hexdump(obj->valuestring, strlen(obj->valuestring));
+#if (defined(_WIN32) || defined(_WIN64))
 		CSimpleStringW strw = "";
 		UTF8ToUnicode(obj->valuestring, strw);
 		dstValue = CSimpleStringW2A(strw);
+#else
+		dstValue = obj->valuestring;
+#endif
 		return true;
 	}
 	strcat(errmsg, "array member ");
@@ -1170,15 +1183,18 @@ bool CWSCodec::GetCJsonObjectValue(cJSON *obj, CSimpleStringA& dstValue, char* e
 
 bool CWSCodec::GetCJsonObjectValue(cJSON *obj, CSimpleStringW& dstValue, char* errmsg){
 	if(cJSON_String == obj->type){
-//		dstValue = obj->valuestring;
+#if (defined(_WIN32) || defined(_WIN64))
 		UTF8ToUnicode(obj->valuestring, dstValue);
+#else
+		dstValue = obj->valuestring;
+#endif
 		return true;
 	}
 	strcat(errmsg, "array member ");
 	dstValue = "";
 	return false;
 }
-
+#if (defined(_WIN32) || defined(_WIN64))
 int CWSCodec::UTF8ToUnicode(char* input, CSimpleStringW& output){
 	//UTF8 to Unicode
 	//预转换,得到所需空间的大小
@@ -1194,7 +1210,7 @@ int CWSCodec::UTF8ToUnicode(char* input, CSimpleStringW& output){
 	wszString = NULL;
 	return 0;
 }
-
+#endif
 void CWSCodec::hexdump(const char *buf, const int num){
 	char str[8192] = { 0 };
 	int i = 0;

+ 2 - 1
Module/mod_chromium/CWSCodec.h

@@ -79,8 +79,9 @@ private:
 	bool GetCJsonObjectValue(cJSON *obj, CSimpleStringA& dstValue, char* errmsg);
 	bool GetCJsonObjectValue(cJSON *obj, CSimpleStringW& dstValue, char* errmsg);
 	bool GetCJsonObjectValue(cJSON *obj, unsigned int& dstValue,    char* errmsg);
-
+#if (defined(_WIN32) || defined(_WIN64))
 	int UTF8ToUnicode(char* input, CSimpleStringW& output);
+#endif
 	void hexdump(const char *buf, const int num);
 private:
 	CStructureInterpreter* mInterpreter;

+ 26 - 17
Module/mod_chromium/CWebsocketServer.cpp

@@ -1,19 +1,21 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
+#include "../mod_browser/IEBrowser_client_g.h"
+#endif
 #include "CWebsocketServer.h"
 #include "baseEx.h"
 #include "CModTools.h"
-#include <boost/thread/thread.hpp>
 #include <vector>
-#include "../mod_browser/IEBrowser_client_g.h"
 #include "MessageType.h"
-
+#include <future>
+#include <boost/thread/thread.hpp>
 #include <boost/thread/lock_guard.hpp>
-//#include <boost/locale.hpp>
+#include <iostream>
 
 namespace Chromium{
 
 CWebsocketServer::CWebsocketServer(const char* strPath, CEntityBase* pEntity):
-m_ios(),m_wsserver(),m_serializer(NULL),m_socket(NULL),m_pEntity(pEntity)
+m_wsserver(), m_ios(),m_serializer(NULL),m_socket(NULL),m_pEntity(pEntity)
 {
 	DbgEx("CWebsocketServer constructor");
 	// Initialize socket client
@@ -41,7 +43,10 @@ m_ios(),m_wsserver(),m_serializer(NULL),m_socket(NULL),m_pEntity(pEntity)
 	init_websocket();
 
 	init_entity_sessions();
-};
+}
+
+
+
 
 void CWebsocketServer::updateMsgPool(std::string entityName, std::string &payload, websocketpp::connection_hdl hdl)
 {
@@ -53,11 +58,12 @@ void CWebsocketServer::updateMsgPool(std::string entityName, std::string &payloa
 		auto &curArr = it->second;
 		for (auto i = curArr.begin(); i != curArr.end(); i++)
 		{
-			if (hdl._Get() == i->first._Get())
+			if (&hdl == &i->first)
 			{
 				curArr.erase(i);
 				break;
 			}
+			
 		}
 		it->second.push_back(std::make_pair(hdl, payload));
 	}
@@ -122,7 +128,7 @@ void CWebsocketServer::deal_msg(std::string &payload, websocketpp::connection_hd
 		storeEntityWithCLass(m_serializer->GetEntityName(payload), m_serializer->GetClassName(payload));
 
 	// Try to manage entity session
-	RequestProcessType processType = this->m_esm->RequestProcess(p, m_serializer->GetEntityName(payload), (unsigned int)hdl.lock().get());
+	RequestProcessType processType = this->m_esm->RequestProcess(p, m_serializer->GetEntityName(payload),  (long)hdl.lock().get());
 
 	switch (processType)
 	{
@@ -177,7 +183,7 @@ void CWebsocketServer::message_handler(websocketpp::connection_hdl hdl, server::
 		*/
 	static int pos = 0;
 	static std::map<int, int> t_hdlArr;
-	int hdlPos = (int)hdl.lock().get();
+	int hdlPos = (long)hdl.lock().get();
 	if (t_hdlArr.end() == t_hdlArr.find(hdlPos))
 		t_hdlArr[hdlPos] = pos++;
 
@@ -204,7 +210,7 @@ void CWebsocketServer::message_handler(websocketpp::connection_hdl hdl, server::
 	};
 	boost::thread dealMsgThread(msgHandleFun);
 	dealMsgThread.join();	
-};
+}
 
 std::string CWebsocketServer::restroreTransId(std::string payLoad)
 {
@@ -224,8 +230,8 @@ void CWebsocketServer::open_handler(websocketpp::connection_hdl hdl){
 	// hand shake here
 	DbgEx("new connection to ws server : %u", hdl.lock().get());
 	
-	m_connection_hdls.insert(std::pair<unsigned int, websocketpp::connection_hdl>((unsigned int)hdl.lock().get(), hdl));
-};
+	m_connection_hdls.insert(std::pair<unsigned int, websocketpp::connection_hdl>((long)hdl.lock().get(), hdl));
+}
 
 void CWebsocketServer::close_handler(websocketpp::connection_hdl hdl){
 	// hand shake here
@@ -239,7 +245,7 @@ void CWebsocketServer::close_handler(websocketpp::connection_hdl hdl){
 		modTools.StartChromiumBrowser();
 	}
 	*/
-};
+}
 
 void CWebsocketServer::do_run(){
 	DbgEx("CWebsocketServer -> do_run");
@@ -272,7 +278,7 @@ void CWebsocketServer::do_relink()
 			DbgEx("try do_relink");
 			auto unlinkArr = m_esm->queryUnLinkSession();
 			boost::lock_guard<boost::mutex> lock(m_dealMsgLock);
-			for each (auto it in unlinkArr)
+			for (auto it : unlinkArr)
 			{
 				auto ret = getEntityClass(it);
 				if (ret.first)
@@ -300,7 +306,7 @@ void CWebsocketServer::run(){
 	boost::thread thread1(boost::bind(&CWebsocketServer::do_run, this));
 	boost::thread thread2(boost::bind(&CWebsocketServer::do_relink, this));
 	
-};
+}
 
 void CWebsocketServer::do_sendJsonBroadcast(std::string js)
 {
@@ -360,7 +366,9 @@ void CWebsocketServer::do_sendJson(std::string js, int hdlID, unsigned int id)
 	if (m_connection_hdls.empty())
 		DbgEx("message_from_socket : no websocket client connection");
 	else {
+#if(defined _WIN32 || defined _WIN64)
 		js = string_to_utf8(js);
+#endif
 		if (js.empty())
 		{
 			DbgEx("string empty 2");
@@ -441,7 +449,7 @@ void CWebsocketServer::message_from_socket(CMessage& msg, unsigned int id){
 	{//sessionAck
 		auto ret = m_esm->AskProcessSession(&msg, hdlID);
 		auto sessionId = msg.getSessionID();
-		if (PROCESS_NOTHING == ret.first)
+		if (ACKPROCESS_NOTHING == ret.first)
 		{
 			DbgEx("can not find save session, process noting, %s", ret.second.c_str());//error
 			return;
@@ -524,7 +532,7 @@ void CWebsocketServer::myTest()
 // 	else
 // 		DbgEx("connect to IEBrowser entity success");
 }
-
+#if(defined _WIN32 || defined _WIN64)
 std::string CWebsocketServer::string_to_utf8(const std::string & str) {
 	LOG_FUNCTION();
 	DbgEx("start string_to_utf8...");
@@ -579,6 +587,7 @@ std::string CWebsocketServer::string_to_utf8(const std::string & str) {
 	}
 	return std::string();
 }
+#endif
 
 void CWebsocketServer::init_entity_sessions(){
 	return;

+ 4 - 1
Module/mod_chromium/CWebsocketServer.h

@@ -1,7 +1,8 @@
 #ifndef CWebsocketServer_h
 #define CWebsocketServer_h
 
-#include "websocketpp/config/asio_no_tls.hpp"
+//#include "websocketpp/config/asio_no_tls.hpp"
+#include "openssl/ec.h"
 #include "websocketpp/config/asio.hpp"
 #include "websocketpp/server.hpp"
 #include "CMessage.h"
@@ -38,7 +39,9 @@ private:
 	void init_entity_sessions();
 	void do_sendJson(std::string js, int hdlID, unsigned int id);
 	void do_sendJsonBroadcast(std::string js);
+#if(defined _WIN32 || defined _WIN64)
 	std::string string_to_utf8(const std::string &str);
+#endif
 	void myTest();
 	void updateMsgPool(std::string entityName, std::string &payload, websocketpp::connection_hdl hdl);
 	void storeEntityWithCLass(std::string entityName, std::string entityClass);

+ 13 - 135
Module/mod_chromium/ChromiumFSM.cpp

@@ -1,14 +1,17 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
-#include "ChromiumFSM.h"
-#include <set>
-#include <string>
-//#include "zmq_utils.h"
 #include <boost/bind.hpp>
 #include "../mod_FreeRDPWrap/FreeRDPWrap_client_g.h"
 #include "../mod_browser/IEBrowser_client_g.h"
+#endif
+#include "ChromiumFSM.h"
+#include <set>
+#include <string>
 #include "Chromium_msg_g.h"
 #include "baseEx.h"
 
+
+
 namespace Chromium{
 
 CChromiumFSM::CChromiumFSM(CEntityBase* pEntity):m_pEntity(pEntity)
@@ -33,8 +36,7 @@ ErrorCodeEnum CChromiumFSM::OnExit(){
 
 
 void CChromiumFSM::s0_on_entry(){
-	// init zmq and start zmq service
-//	m_hZmqServerThread = new boost::thread(boost::bind(&CChromiumFSM::zmq_stream_server_proc, this));
+
 }
 
 void CChromiumFSM::s0_on_exit(){
@@ -69,135 +71,7 @@ unsigned int CChromiumFSM::s2_on_event(FSMEvent* e){
 	return 0;
 }
 
-//ZmqStreamServerProc - 服务端线程函数
-// void CChromiumFSM::zmq_stream_server_proc() {
-// 
-// 	int rc;
-// 	std::set<std::string> peer_ids;
-// 	DWORD prev_tick = GetTickCount();
-// 
-// 	// init zmq and start zmq service
-// 	if((m_pZmqCtx = zmq_ctx_new()) == NULL){
-// 		DbgEx("zmq_ctx_new failled!");
-// //		Sleep(50);
-// 		return;
-// 	}
-// 	// init zmq socket
-// 	if((m_pZmqSock == zmq_socket(m_pZmqCtx, ZMQ_STREAM))){
-// 		DbgEx("zmq_socket failed");
-// //		Sleep(50);
-// 		return;
-// 	}
-// 
-// 	int enabled = 1;
-// 	rc = zmq_setsockopt(m_pZmqSock, ZMQ_STREAM_NOTIFY, &enabled, sizeof(enabled));
-// 	if (rc != 0)
-// 	{
-// 		DbgEx("zmq_setsockopt failed");
-// 		return;
-// 	}
-// 
-// 	rc = zmq_bind(m_pZmqSock, m_strZmqAddr);
-// 	if (rc != 0)
-// 	{
-// 		DbgEx("zmq_bind failed");
-// 		return;
-// 	}
-// 
-// 	while (true) {
-// 		// check interrupt point
-// 		boost::this_thread::interruption_point();
-// 		//对socket进行poll操作
-// 		zmq_pollitem_t items[] = {
-// 			{ m_pZmqSock, 0, ZMQ_POLLIN, 0 },
-// 		};
-// 		rc = zmq_poll(items, 1, 100);
-// 
-// 		if (rc == 1) {
-// 
-// 			if (items[0].revents & ZMQ_POLLIN) {
-// 				//有数据可读,分为两种情况,一种是STREAM NOTIFY,一种是真实的客户端发出的数据
-// 
-// 				zmq_msg_t peer_frame;
-// 
-// 				//接收1st 对端ID帧
-// 				rc = zmq_msg_init(&peer_frame);
-// //				assert(rc == 0);
-// 				rc = zmq_msg_recv(&peer_frame, m_pZmqSock, 0);
-// //				assert(rc != -1);
-// //				assert(zmq_msg_size(&peer_frame) > 0);
-// //				assert(has_more(m_pZmqSock));
-// 				char * p_peer_frame_data = (char*)zmq_msg_data(&peer_frame);
-// 				//DbgEx("peer_id:%s\n", p_peer_frame_data);
-// 
-// 				std::string str_peer_id(p_peer_frame_data, zmq_msg_size(&peer_frame));
-// 				zmq_msg_close(&peer_frame);
-// 
-// 				//接收2nd 对端数据帧
-// 				zmq_msg_t data_frame;
-// 				rc = zmq_msg_init(&data_frame);
-// //				assert(rc == 0);
-// 				rc = zmq_msg_recv(&data_frame, m_pZmqSock, 0);
-// //				assert(rc != -1);
-// 				if (zmq_msg_size(&data_frame) == 0) {
-// 					if (peer_ids.find(str_peer_id) == peer_ids.end()) {
-// 						DbgEx("S :a new conn incoming\n");
-// 						peer_ids.insert(str_peer_id);
-// 					}
-// 					else {
-// 						DbgEx("S :an exsit conn disconnected\n");
-// 						peer_ids.erase(str_peer_id);
-// 					}
-// 				}
-//  				else {
-// 					char * p_data_frame_data = (char*)zmq_msg_data(&data_frame);
-// 					DbgEx("S :recv [%s]\n", p_data_frame_data);
-// 				}
-// 				zmq_msg_close(&data_frame);
-// 			}
-// 
-// 			/*if (items[0].revents & ZMQ_POLLERR) {
-// 				DbgEx("S :ZMQ_POLLERR\n");
-// 			}*/
-// 
-// 		}
-// 		else if (rc == 0) {
-// 			//0 表示poll没有相应事件,可认为socket出于空闲状态。
-// 			//DbgEx("S :zmq_poll() return 0\n");
-// 			//assert(false);
-// 
-// 			//模拟每3秒钟给所有客户端发出请求
-// 			if (peer_ids.size() > 0 && (GetTickCount() - prev_tick) > 3000) {
-// 				for (auto iter = peer_ids.begin(); iter != peer_ids.end(); ++iter) {
-// 
-// 					//服务器端先发出请求
-// 					//发出1st ID帧
-// 					rc = zmq_send(m_pZmqSock, iter->c_str(), iter->size(), ZMQ_SNDMORE);
-// 					//DbgEx("S :send identity res=%d errno=%d\n", rc, errno);
-// 					//assert(rc != -1);
-// 
-// 					//发出2nd 数据帧
-// 					DbgEx("S :send:[%s]\n", "hello");
-// 					rc = zmq_send(m_pZmqSock, "hello", 6, ZMQ_SNDMORE);
-// 					//assert(rc != -1);
-// 				}
-// 				prev_tick = GetTickCount();
-// 			}
-// 		}
-// 		else {
-// 			DbgEx("S :zmq_poll() return error\n");
-// //			assert(false);
-// 		}
-// 	}
-// 	rc = zmq_close(m_pZmqSock);
-// //	assert(rc == 0);
-// 
-// 	rc = zmq_ctx_term(m_pZmqCtx);
-// //	assert(rc == 0);
-// 
-// 	return ;
-// }
-
+#if (defined _WIN32 || defined _WIN64)
 void CChromiumFSM::start_chromium_browser(){
 	using namespace FreeRDPWrap;
 	FreeRDPWrapSrv_ClientBase *pClient = new FreeRDPWrapSrv_ClientBase(m_pEntity);
@@ -222,5 +96,9 @@ void CChromiumFSM::start_chromium_browser(){
 		}
 	}
 }
+#else
+void CChromiumFSM::start_chromium_browser() {
+}
+#endif
 
 }

+ 1 - 3
Module/mod_chromium/ChromiumFSM.h

@@ -54,11 +54,9 @@ public:
 
 private:
 	CEntityBase* m_pEntity;
-// 	void* m_pZmqCtx;
-// 	void* m_pZmqSock;
-// 	const char* m_strZmqAddr;
 	void start_chromium_browser();
 
+
 };
 
 }

+ 4 - 2
Module/mod_chromium/EntitySessionManager.cpp

@@ -1,4 +1,6 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
+#endif
 #include "MessageType.h"
 #include "EntitySessionManager.h"
 #include "baseEx.h"
@@ -59,7 +61,7 @@ void EntitySessionManager::StoreSessionReq(int transID, std::string entityName){
 std::vector<std::string> EntitySessionManager::queryUnLinkSession()
 {
 	std::vector<std::string> ret;
-	for each (auto it in m_session_map)
+	for (auto it : m_session_map)
 	{
 		if (it.second == -1)
 			ret.push_back(it.first);
@@ -393,7 +395,7 @@ AckProcessType EntitySessionManager::ProcessWithAck(CMessage* msg, unsigned int
 
 std::pair<bool, std::string> EntitySessionManager::DoSessionRemove(unsigned int session)
 {
-	for each(auto it in m_session_map)
+	for (auto it : m_session_map)
 	{
 		if (it.second == session)
 		{

+ 34 - 2
Module/mod_chromium/baseEx.cpp

@@ -1,13 +1,45 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
+#endif
+
 #include "baseEx.h"
-#include <Windows.h>
+#include <thread>
+#include <boost/xpressive/xpressive_dynamic.hpp>
+#include <boost/algorithm/string.hpp>
+#include <boost/filesystem.hpp>
 
 
 void DbgEx(const char* str, ...)
 {
 	va_list arg;
 	va_start(arg, str);
-	auto modifyStr = CSimpleString::Format("<%d>--%s", GetCurrentThreadId(), str);
+	auto modifyStr = CSimpleString::Format("<%d>--%s", std::this_thread::get_id(), str);
 	vDbg(modifyStr.GetData(), arg);
 	va_end(arg);
 }
+
+std::vector<std::string> find_files(const std::string srcPath, const std::string fileName)
+{
+	static boost::xpressive::sregex_compiler rc;
+	if (!rc[fileName].regex_id())
+	{
+		std::string str = boost::algorithm::replace_all_copy(
+			boost::algorithm::replace_all_copy(fileName, ".", "\\."), "*", ".*");
+		rc[fileName] = rc.compile(str);
+	}
+
+	std::vector<std::string> ret;
+
+	if (!boost::filesystem::exists(srcPath) || !boost::filesystem::is_directory(srcPath))
+		return ret;
+
+	typedef boost::filesystem::recursive_directory_iterator rd_iterator;
+	rd_iterator end;
+	for(rd_iterator pos(srcPath); pos != end; ++pos)
+	{
+		if (!boost::filesystem::is_directory(*pos) && boost::xpressive::regex_match(pos->path().filename().string(), rc[fileName]))
+			ret.push_back(pos->path().string());
+	}
+
+	return ret;
+}

+ 4 - 1
Module/mod_chromium/baseEx.h

@@ -1,4 +1,7 @@
 #pragma once
 #include "SpBase.h"
+#include<vector>
+#include<string>
 
-void DbgEx(const char* str, ...);
+void DbgEx(const char* str, ...);
+std::vector<std::string> find_files(const std::string srcPath, const std::string fileName);

+ 17 - 38
Module/mod_chromium/mod_chromium.cpp

@@ -1,12 +1,14 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
+#include <Windows.h>
+#include <WinUser.h>
+#endif
 #include "baseEx.h"
 #include "CWebsocketServer.h"
 #include "mod_chromium.h"
 #include "base64.h"
 #include "CModTools.h"
 #include "cJSON.h"
-#include <Windows.h>
-#include <WinUser.h>
 #include "SpIni.h"
 #include "CSocketClient.h"
 #include "processControl.h"
@@ -24,15 +26,7 @@ namespace Chromium{
 
 CChromiumEntity::CChromiumEntity():m_pWsServer(NULL), m_iTcpBridgePort(4504),m_pTimerListener(NULL)
 {
-	InitializeCriticalSection(&g_csInvokFreeRDP);
 	DbgEx("CChromiumEntity constructor");
-	/*
-	m_hIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
-	boost::thread(boost::bind(&CChromiumEntity::JobNotify, this)).detach(); //后台自动运行
-	m_job.Create(NULL, NULL);
-	m_job.SetEndOfJobInfo(JOB_OBJECT_POST_AT_END_OF_JOB);
-	m_job.AssociateCompletionPort(m_hIOCP, COMPKEY_JOBOBJECT);
-	*/
 
 	boost::thread(boost::bind(&CChromiumEntity::CefClintNotify, this)).detach(); //后台自动运行
 
@@ -45,11 +39,11 @@ CChromiumEntity::~CChromiumEntity()
 		free(m_pWsServer);
 		m_pWsServer = NULL;
 	}
-	DeleteCriticalSection(&g_csInvokFreeRDP);
+	//DeleteCriticalSection(&g_csInvokFreeRDP);
 }
 
 
-
+#if (defined _WIN32 || defined _WIN64)
 void CChromiumEntity::JobNotify() {
 	TCHAR sz[2000];
 	BOOL fDone = FALSE;
@@ -108,6 +102,7 @@ void CChromiumEntity::JobNotify() {
 		}
 	}
 }
+#endif
 
 void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext)
 {
@@ -119,7 +114,7 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 	ErrorCodeEnum Error;
 	CSmartPointer<IEntityFunction> spEntityFunction = GetFunction();
 	Error = spEntityFunction->StartTcpBridgeServer(m_iTcpBridgePort);
-	
+#if (defined _WIN32 || defined _WIN64)
 	Error = spEntityFunction->SubscribeBroadcast("IEBrowser", "CustomerCmd", this, m_uidBrowserListenser);
 	if (Error != Error_Succeed) {
 	 	LOG_TRACE("subscribe browser CustomerCmd failed!");
@@ -127,6 +122,7 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 	}
 	else
 	 	LOG_TRACE("subscribe browser CustomerCmd success!");
+#endif
 
 	if (Error != Error_Succeed) 
 	{
@@ -166,6 +162,7 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 
  void CChromiumEntity::CefClintNotify()
  {
+#if(defined _WIN32 || defined _WIN64)
 	 while (1)
 	 {
 		 for (auto it = m_cefArr.begin(); it != m_cefArr.end(); it++)
@@ -180,6 +177,7 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 				 auto cmdline = std::get<2>(it->second);//save the param
 
 				 TerminateJobObject(std::get<0>(it->second), 0);
+
 				 m_cefArr.erase(it->first);
 
 				 auto startRet = startProcessInJob(cmdline, "");
@@ -190,8 +188,9 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 		 }
 		 boost::this_thread::sleep_for(boost::chrono::seconds(10));
 	 }
+#endif
  }
-
+#if (defined _WIN32 || defined _WIN64)
  void CChromiumEntity::OnCustomerCmd(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, IEBrowser::CustomerCmd& evt)
  {
 	 DbgEx("OnCustomerCmd %s", evt.cmdStr);
@@ -226,13 +225,6 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 		 // 需要保存启动的chromium的句柄值或者进程Id,通过该进程Id来获取句柄管理chromium运行
 		 // 因为有多个chromium,此时对每一个H5页面,都保存连接。并无法感知到某一个chromium的连接都不存在来重启chromium
 
-		 /*
-		 if (historyChromium.second == info)
-		 {
-			 KillProcessById(historyChromium.first);
-			 historyChromium = std::make_pair(0, "");
-		 }
-		 */
 		 chromiumCLoseInJob(info);
 
 		 CSmartPointer<IConfigInfo> spCerConfig;
@@ -271,14 +263,6 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 		 DbgEx("ChromiumStart cmdline : %s", strCmdLine);
 
 
-		 //control cefclient throught processId
-		 /*
-		 auto processInfo = StartProcess(strCmdLine.GetData(), "", true);
-		 if (nullptr != processInfo.first)
-			 historyChromium = std::make_pair(processInfo.second, info);
-		 else
-			 DbgEx("start chromium failed");
-			 */
 
 		 //control cefclient throught job
 		 auto startRet = startProcessInJob(strCmdLine.GetData(), "");
@@ -293,18 +277,10 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 
 
 
-		 /*
-		 if (historyChromium.second == info)
-		 {
-			 KillProcessById(historyChromium.first);
-			 historyChromium = std::make_pair(0, "");
-		 }
-		 */
 		 chromiumCLoseInJob(info);
 	 }
-
-	 
  }
+#endif
 
  void CChromiumEntity::generateCefclientTimer()
  {
@@ -335,6 +311,7 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 	 
 	 if (rc.first == Error_Succeed && rc.second != 0)
 	 {
+#if (defined _WIN32 || defined _WIN64)
 		 HANDLE defaultProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, rc.second);
 		 if (defaultProcess == nullptr)
 		 {
@@ -366,7 +343,9 @@ void CChromiumEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointe
 			 };
 			 if(ret.second != nullptr && defaultProcess != nullptr)
 				boost::thread(monitorThread, ret.second, defaultProcess).detach();
+
 		 }
+#endif
 	 }
 	 
 

+ 14 - 8
Module/mod_chromium/mod_chromium.h

@@ -2,18 +2,22 @@
 #define _CHROMIUM_ENTITY_H
 #include "Chromium_server_g.h"
 
-#include "..\\mod_browser\\IEBrowser_client_g.h"
-#include "..\\mod_browser\\IEBrowser_def_g.h"
-#include "..\\mod_browser\\IEBrowser_msg_g.h"
-
 #include<map>
 #include<string>
 #include<tuple>
+#if (defined _WIN32 || defined _WIN64)
 #include "job.h"
+#include "..\\mod_browser\\IEBrowser_client_g.h"
+#include "..\\mod_browser\\IEBrowser_def_g.h"
+#include "..\\mod_browser\\IEBrowser_msg_g.h"
+#endif
 
 #pragma once
 namespace Chromium{
-class CChromiumEntity : public CEntityBase  , public IBroadcastListener
+class CChromiumEntity : public CEntityBase 
+#if (defined _WIN32 || defined _WIN64)
+	, public IBroadcastListener
+#endif
 {
 public:
 	CChromiumEntity();
@@ -24,11 +28,13 @@ public:
 
 	virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmartPointer<ITransactionContext> pTransactionContext);
 	virtual void OnPreClose(EntityCloseCauseEnum eCloseCause,CSmartPointer<ITransactionContext> pTransactionContext);
-	void JobNotify();
 	void CefClintNotify();
 private :
 	void OnTaskTimerListener(void *pData);
+#if (defined _WIN32 || defined _WIN64)
+	void JobNotify();
 	void OnCustomerCmd(const char* pszEntityName, DWORD dwMessageId, DWORD dwMessageSignature, IEBrowser::CustomerCmd& evt);
+#endif
 	void generateCefclientTimer();
 private:
 	CSystemStaticInfo m_sysInfo;
@@ -37,16 +43,16 @@ private:
 	int m_iTcpBridgePort;
 	CUUID m_uidBrowserListenser;
 	std::map<std::string, std::tuple<HANDLE, HANDLE, std::string>> m_cefArr;//open discribe: slv, job Handle, process Handle, cmdline
-	CJob m_job;
 	HANDLE m_hIOCP;
 	HANDLE m_hThreadIOCP;
 	
-
+#if (defined _WIN32 || defined _WIN64)
 	SP_BEGIN_MSG_DISPATCH_MAP(CBrowserEntity)
 		SP_BEGIN_ENTITY_MSG("IEBrowser")
 		SP_MSG_HANDLE_NS(IEBrowser, CustomerCmd, OnCustomerCmd)
 		SP_END_ENTITY_MSG()
 	SP_END_MSG_DISPATCH_MAP()
+#endif
 };
 
 }

+ 7 - 3
Module/mod_chromium/portCheck/portCheck.cpp

@@ -1,11 +1,15 @@
+#if (defined _WIN32 || defined _WIN64)
 #include "stdafx.h"
-#include <stdio.h>
 #include <winsock.h>
-#include <string>
 #pragma comment(lib,"Ws2_32.lib")
-
 #include "Wininet.h"  
 #pragma comment(lib,"Wininet.lib") 
+#endif
+#include <stdio.h>
+#include <string>
+
+
+
 
 
 bool checkHttpActive(const char *httpUrl)

+ 55 - 36
Module/mod_chromium/processControl.cpp

@@ -2,6 +2,52 @@
 #include "processControl.h"
 #include "baseEx.h"
 
+
+
+
+
+
+#if(defined _WIN32 || defined _WIN64)
+bool KillProcessById(DWORD pID)
+{
+	HANDLE Hwnd;
+	bool ret = false;
+	Hwnd = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, 0, pID);
+	if (Hwnd)
+	{
+		if (TerminateProcess(Hwnd, 0))
+		{
+			ret = true;
+		}
+	}
+	return ret;
+}
+
+std::tuple<bool, HANDLE, HANDLE> startProcessInJob(std::string program, std::string args)
+{
+	PROCESS_INFORMATION processInfo;
+	ZeroMemory(&processInfo, sizeof(processInfo));
+
+	STARTUPINFO startupInfo;
+	::ZeroMemory(&startupInfo, sizeof(startupInfo));
+	startupInfo.cb = sizeof(startupInfo);
+	startupInfo.dwFlags = STARTF_USESHOWWINDOW;
+	startupInfo.wShowWindow = SW_HIDE;
+
+	std::string runInfo = program + std::string(" ") + args;
+
+	BOOL retVal = ::CreateProcessA(NULL, const_cast<char*>(runInfo.c_str()), NULL, NULL, FALSE,
+		CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &startupInfo, &processInfo);
+	if (!processInfo.hProcess)
+	{
+		DbgEx("CreateProcess failed!, %s", runInfo.c_str());
+		return std::make_tuple(false, (HANDLE)NULL, (HANDLE)NULL);
+	}
+
+	auto ret = assigntoJob(processInfo.hProcess, processInfo.dwProcessId);
+
+	return std::make_tuple(ret.first, ret.second, processInfo.hProcess);
+}
 #pragma comment(lib, "User32.lib")
 
 
@@ -99,43 +145,16 @@ std::pair<bool, HANDLE> assigntoJob(HANDLE process, int pid)
 	}
 }
 
-std::tuple<bool, HANDLE, HANDLE> startProcessInJob(std::string program, std::string args)
-{
-	PROCESS_INFORMATION processInfo;
-	ZeroMemory(&processInfo, sizeof(processInfo));
 
-	STARTUPINFO startupInfo;
-	::ZeroMemory(&startupInfo, sizeof(startupInfo));
-	startupInfo.cb = sizeof(startupInfo);
-	startupInfo.dwFlags = STARTF_USESHOWWINDOW;
-	startupInfo.wShowWindow = SW_HIDE;
-
-	std::string runInfo = program + std::string(" ") + args;
-
-	BOOL retVal = ::CreateProcessA(NULL, const_cast<char*>(runInfo.c_str()), NULL, NULL, FALSE,
-		CREATE_BREAKAWAY_FROM_JOB, NULL, NULL, &startupInfo, &processInfo);
-	if (!processInfo.hProcess)
-	{
-		DbgEx("CreateProcess failed!, %s", runInfo.c_str());
-		return std::make_tuple(false, (HANDLE)NULL, (HANDLE)NULL);
-	}
-
-	auto ret = assigntoJob(processInfo.hProcess, processInfo.dwProcessId);
-
-	return std::make_tuple(ret.first, ret.second, processInfo.hProcess);
+#else
+std::tuple<bool, long, long> startProcessInJob(std::string program, std::string args)
+{
+	return std::make_tuple(true, 1, 1);
 }
 
-bool KillProcessById(DWORD pID)
+std::pair<bool, long> assigntoJob(long process, int pid)
 {
-	HANDLE Hwnd;
-	bool ret = false;
-	Hwnd = OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, 0, pID);
-	if (Hwnd)
-	{
-		if (TerminateProcess(Hwnd, 0))
-		{
-			ret = true;
-		}
-	}
-	return ret;
-}
+	return std::make_pair(true, 1);
+}
+
+#endif

+ 10 - 7
Module/mod_chromium/processControl.h

@@ -1,18 +1,21 @@
 #pragma once
+#if (defined _WIN32 || defined _WIN64)
 #include <Windows.h>
 #include <WinUser.h>
+#endif
 #include <iostream>
 #include <tuple>
 #include <string>
 
 
 
-HWND GetWindowHwndByPID(DWORD dwProcessID);
-
+#if(defined _WIN32 || defined _WIN64)
+bool KillProcessById(DWORD pID);
+std::tuple<bool, HANDLE, HANDLE> startProcessInJob(std::string program, std::string args);
 std::pair<HANDLE, int> StartProcess(std::string program, std::string args, BOOL isEnum);
-
+HWND GetWindowHwndByPID(DWORD dwProcessID);
 std::pair<bool, HANDLE> assigntoJob(HANDLE process, int pid);
-
-std::tuple<bool, HANDLE, HANDLE> startProcessInJob(std::string program, std::string args);
-
-bool KillProcessById(DWORD pID);
+#else
+std::tuple<bool, long, long> startProcessInJob(std::string program, std::string args);
+std::pair<bool, long> assigntoJob(long process, int pid);
+#endif