本文整理汇总了C++中CSession::SetData方法的典型用法代码示例。如果您正苦于以下问题:C++ CSession::SetData方法的具体用法?C++ CSession::SetData怎么用?C++ CSession::SetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSession
的用法示例。
在下文中一共展示了CSession::SetData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RouteHandler
int CMain::RouteHandler(CCliPeer *a_cPeer, CProtocol *cProto)
{
bool blnRet = 0;
int nRet = 0;
time_t curTm = 0;
CCliReq *cDecReq;
string strPkgName;
string strCmdName;
string strPayload;
CSession *cSession = NULL;
CGlobal *cGlob = NULL;
CModuleIPC *cIpc = NULL;
int unDstNodeNo = 0;
int unDstNo = 0;
unsigned int nClcSessionId = 0;
strPayload = cProto->GetPayload();
cDecReq = new CCliReq();
nRet = cDecReq->DecodeMessage(strPayload);
if(nRet != CCliApi::RESULT_OK){
return CLA_NOK;
}
curTm = time(NULL);
if(m_cHistLog != NULL){
char szTime[62];
struct tm *t = NULL;
t = localtime(&curTm);
strftime(szTime, 62, "%04Y-%02m-%02d %02H:%02M:%02S",t);
m_cHistLog->INFO("[%s:%s] %s\n",a_cPeer->GetUserId().c_str(), szTime, cDecReq->GetCmdLine().c_str());
}
strPkgName = cDecReq->GetPkgName();
strCmdName = cDecReq->GetCmdName();
if(strPkgName.size() == 0){
strPkgName = "ATOM";
}
nRet = m_cCliRoute.FindDestinationNo(strCmdName, strPkgName, &unDstNo, &unDstNodeNo);
if(nRet != CLA_OK){
CLA_LOG(CLA_ERR,false,"Can not find destination(cmd=%s, pkg=%s)\n", strCmdName.c_str(), strPkgName.c_str());
return CLA_NOK;
}
/* reload message */
nClcSessionId = cProto->GetSequence();
cDecReq->SetSessionId(m_nSessionSeq);
cDecReq->EncodeMessage(strPayload);
/* make c protocol */
cGlob = CGlobal::GetInstance();
cProto->SetPayload(strPayload);
cProto->SetSequence(m_nSessionSeq);
cProto->SetSource(cGlob->GetLocalNodeNo(),cGlob->GetLocalProcNo());
cProto->SetDestination(unDstNodeNo,unDstNo);
cProto->SetFlagRequest();
cProto->SetCommand("0000080001");
cIpc = cGlob->GetModuleIPC();
/* make session */
cSession = new CSession();
cSession->Init(m_nSessionSeq++, a_cPeer->GetSocketFd(),a_cPeer->GetTimestamp(), curTm);
cSession->SetClcSessionId(nClcSessionId);
cSession->SetData(unDstNo, unDstNodeNo, cProto, cDecReq);
blnRet = cIpc->SendMesg(*cProto);
if(blnRet != true){
CLA_LOG(CLA_ERR,false,"IPC Send failed(CLI REQUEST)\n");
a_cPeer->SendError(nClcSessionId, CLA_RSLT_CODE_SEND_ERROR);
nRet = UpdateHistErr(cSession, CLA_RSLT_CODE_SEND_ERROR);
delete cSession;
return CLA_NOK;
}
m_lstSession.push_back(cSession);
return CLA_OK;
}