ContentHandle* ContentManager::ReadFile(std::wstring fileName) { auto p = MakePath(fileName); ContentHandle* ch = nullptr; if (m_dictHandles.TryGet(p, &ch)) { if (ch && !ch->IsClosed()) return ch; } else if (m_dictHandles.TryGet(fileName, &ch)) { if (ch && !ch->IsClosed()) return ch; } if (PathExists(p)) { ch = new ContentHandle(p); if (ch->GetStream()->operator!()) ch = nullptr; if (ch) RegisterHandle(p, ch); } else { Formats::SMC::smcs_info inf; if (m_pSystem->GetEntry(fileName, &inf)) { ch = new ContentHandle(inf); if (ch) RegisterHandle(fileName, ch); } } return ch; }
bool ServerHandler::HandleProtocolData(const Json::Value &value, LPMESSAGE_DATA pMsgData) { CAutoLock lock(&m_mutexReset); bool result = false; gvLog(LOG_MSG, "(ServerHandler::HandleProtocolData) MSG: in lock"); if (value.isMember(CMD_PARAM) && value[CMD_PARAM].isString()){ string strCmd = value[CMD_PARAM].asString(); if (0 == strCmd.compare(GET_SERVER_CHANLLENGE_CMD) && GET_CHANLLENGE_STEP == m_eHandleStep) { result = GetChanllengeHandle(value, pMsgData); } else if (0 == strCmd.compare(REGISTER_CMD) && REGISTER_SERVER_STEP == m_eHandleStep) { result = RegisterHandle(value, pMsgData); } else if (0 == strCmd.compare(PUSHMSG_CMD) && PUSHMESSAGE_STEP == m_eHandleStep) { Json::FastWriter writer; string strJson = writer.write(value); gvLog(LOG_MSG, "(ServerHandler::HandleProtocolData) MSG: PushMessageHandle body:%s", strJson.c_str()); result = PushMessageHandle(value, pMsgData); } else { gvLog(LOG_ERR_USER, "(ServerHandler::HandleProtocolData) ERR: strCmd:%s\tm_eHandleStep:%d", strCmd.c_str(), m_eHandleStep); } } else { gvLog(LOG_ERR_USER, "(ServerHandler::HandleProtocolData) ERR: CMD_PARAM not found"); } gvLog(LOG_MSG, "(ServerHandler::HandleProtocolData) MSG: out lock"); return result; }