|
|
@@ -130,9 +130,8 @@ namespace Chromium {
|
|
|
m_esm->updateBeginSessionTime(entityName);
|
|
|
WriteToFramework(sessionBuf);
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
DbgEx("Already begin session in 5s, %s", entityName.c_str());
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
void CWebsocketServer::WriteToFramework(CMessage* msg)
|
|
|
@@ -281,9 +280,8 @@ namespace Chromium {
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
- else if (ret.first == BeginSession) {
|
|
|
+ else if (ret.first == BeginSession)
|
|
|
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), (long)hdl.lock().get());
|
|
|
@@ -294,7 +292,7 @@ namespace Chromium {
|
|
|
DbgEx("do PROCESS_NOTHING");
|
|
|
return;
|
|
|
case Chromium::PROCESS_SEND:
|
|
|
- DbgEx("do PROCESS_SEND");
|
|
|
+ //DbgEx("do PROCESS_SEND");
|
|
|
if (nullptr != p)
|
|
|
WriteToFramework(p);
|
|
|
break;
|
|
|
@@ -340,12 +338,15 @@ namespace Chromium {
|
|
|
if (t_hdlArr.end() == t_hdlArr.find(hdlPos))
|
|
|
t_hdlArr[hdlPos] = pos++;
|
|
|
|
|
|
+
|
|
|
auto msgHandleFun = [&]() {
|
|
|
+ //DbgEx("CWebsocketServer -> message_handler");
|
|
|
std::string payload = msg->get_payload();
|
|
|
// proto convert here
|
|
|
#if (defined _WIN32 || defined _WIN64)
|
|
|
payload = utf8_to_string(payload);//windows web utf8, terminal gbk
|
|
|
#endif
|
|
|
+
|
|
|
std::shared_ptr<cJSON> pJson(cJSON_Parse(payload.c_str()), [](cJSON* p) {
|
|
|
if (nullptr != p)
|
|
|
cJSON_Delete(p);
|
|
|
@@ -451,46 +452,22 @@ namespace Chromium {
|
|
|
|
|
|
auto checkEntityIsNoStart = [&](std::string entityName) -> bool
|
|
|
{
|
|
|
- /*
|
|
|
- enum EntityStateEnum
|
|
|
- {
|
|
|
- EntityState_NoStart = 0, //no start before
|
|
|
- EntityState_Starting, //Entity is doing initial
|
|
|
- EntityState_Idle, //after started succeed,and have no work
|
|
|
- EntityState_Busy, //Doing Request-Answer,timing,and Pausing or coninuing work
|
|
|
- EntityState_Pause, //Pause state
|
|
|
- EntityState_UnLoading, //doing cleanning after trigger close
|
|
|
- EntityState_Lost, //Entity block not respond or exception
|
|
|
- EntityState_Close, //After close,start before
|
|
|
- EntityState_Killed, //The entity terminated as block state
|
|
|
- };
|
|
|
-
|
|
|
- */
|
|
|
CSmartPointer<IEntityFunction> spFunc = m_pEntity->GetFunction();
|
|
|
LOG_ASSERT(spFunc != NULL);
|
|
|
CEntityStaticInfo StaticInfo;
|
|
|
CEntityRunInfo RunInfo;
|
|
|
- bool result(false);
|
|
|
|
|
|
do {
|
|
|
+ if (Error_Succeed != spFunc->GetEntityStaticInfo(entityName.c_str(), StaticInfo))
|
|
|
+ break;
|
|
|
|
|
|
- ErrorCodeEnum ec = spFunc->GetEntityStaticInfo(entityName.c_str(), StaticInfo);
|
|
|
- if (ec != Error_Succeed) {
|
|
|
- result = (ec == Error_NotExist);
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- ec = spFunc->GetEntityRunInfo(entityName.c_str(), RunInfo);
|
|
|
- if (ec != Error_Succeed) {
|
|
|
- result = (ec == Error_NotExist);
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- result = (RunInfo.eState == EntityState_NoStart);
|
|
|
+ if (Error_Succeed != spFunc->GetEntityRunInfo(entityName.c_str(), RunInfo))
|
|
|
+ break;
|
|
|
|
|
|
+ return RunInfo.eState == EntityState_NoStart;
|
|
|
} while (false);
|
|
|
|
|
|
- return result;
|
|
|
+ return true;
|
|
|
};
|
|
|
|
|
|
|
|
|
@@ -503,6 +480,7 @@ namespace Chromium {
|
|
|
boost::lock_guard<boost::mutex> lock(m_dealMsgLock);
|
|
|
std::string breakEntityStr = "";
|
|
|
std::string noStartEntity = "";
|
|
|
+ std::string noServerEntity = "";
|
|
|
#if (defined _WIN32 || defined _WIN64)
|
|
|
for each (auto it in unlinkArr)
|
|
|
#else
|
|
|
@@ -517,6 +495,16 @@ namespace Chromium {
|
|
|
noStartEntity.append("|").append(it);
|
|
|
continue;
|
|
|
}
|
|
|
+
|
|
|
+ if (!CWSCodec::getInstance()->checkEntityHasService(it))
|
|
|
+ {
|
|
|
+ if (noServerEntity.empty())
|
|
|
+ noServerEntity.append(it);
|
|
|
+ else
|
|
|
+ noServerEntity.append("|").append(it);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
auto ret = getEntityClass(it);
|
|
|
@@ -532,7 +520,7 @@ namespace Chromium {
|
|
|
DbgEx("unable find class of entity %s", it.c_str());
|
|
|
}
|
|
|
if (!breakEntityStr.empty())
|
|
|
- DbgEx("try to relink entity : %s, noStartEntity: %s", breakEntityStr.c_str(), noStartEntity.c_str());
|
|
|
+ DbgEx("try to relink entity : %s, noStartEntity: %s, noServerEntity: %s", breakEntityStr.c_str(), noStartEntity.c_str(), noServerEntity.c_str());
|
|
|
}
|
|
|
catch (...)
|
|
|
{
|