本文整理汇总了C++中CommData::SetSerialID方法的典型用法代码示例。如果您正苦于以下问题:C++ CommData::SetSerialID方法的具体用法?C++ CommData::SetSerialID怎么用?C++ CommData::SetSerialID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommData
的用法示例。
在下文中一共展示了CommData::SetSerialID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddToSendMessage
MSGSERIALID CommManager::AddToSendMessage( LPCTSTR clientid, const CommData& commData, BOOL bNeedReply /*= TRUE*/ )
{
static MSGSERIALID s_serialid = 0;
if (0 == s_serialid)
{
__time64_t now;
_time64(&now);
s_serialid = now;
}
CPGUID cpguid;
if (! CutupProtocol::Str2CPGuid(clientid, cpguid))
{
errorLog(_T("transfer clientid failed[%s]"), clientid);
return INVALID_MSGSERIALID;
}
MSGSERIALID ret = INVALID_MSGSERIALID;
if (bNeedReply)
{
m_mapSection.Enter();
{
ClientDataMap::iterator finditer = m_clientDataMap.find(clientid);
if (finditer == m_clientDataMap.end())
{
DataMap am;
std::pair<ClientDataMap::iterator, bool> res = m_clientDataMap.insert(ClientDataMap::value_type(clientid, am));
if (res.second)
{
finditer = res.first;
}
}
if (finditer != m_clientDataMap.end())
{
DataMap& am = finditer->second;
SEND_AND_REPLY tempAA;
std::pair<DataMap::iterator, bool> res = am.insert(DataMap::value_type(s_serialid, tempAA));
if (res.second)
{
SEND_AND_REPLY& aa = res.first->second;
aa.bReply = FALSE;
aa.sendData = commData;
aa.sendData.SetSerialID(s_serialid);
aa.cpSerial = 0;
ret = s_serialid;
ByteBuffer toSendData;
aa.sendData.Serialize(toSendData);
BOOL bPutMsg = m_cp.PutMessage(cpguid, toSendData, toSendData.Size(), COMMNAME_DEFAULT, 0, &aa.cpSerial);
if (! bPutMsg)
{
errorLog(_T("put message msgid[%I64u] failed"), aa.sendData.GetMsgID());
}
}
s_serialid++;
}
}
m_mapSection.Leave();
}
else
{
m_mapSection.Enter();
{
CommData sendData = commData;
sendData.SetSerialID(s_serialid);
ret = s_serialid;
ByteBuffer toSendData;
sendData.Serialize(toSendData);
CPSERIAL cpSerial = 0;
BOOL bPutMsg = m_cp.PutMessage(cpguid, toSendData, toSendData.Size(), COMMNAME_DEFAULT, 0, &cpSerial);
if (! bPutMsg)
{
errorLog(_T("put message msgid[%I64u][noreply] failed"), sendData.GetMsgID());
}
s_serialid++;
}
m_mapSection.Leave();
}
return ret;
}