本文整理汇总了C++中CImPdu::GetCommandId方法的典型用法代码示例。如果您正苦于以下问题:C++ CImPdu::GetCommandId方法的具体用法?C++ CImPdu::GetCommandId怎么用?C++ CImPdu::GetCommandId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CImPdu
的用法示例。
在下文中一共展示了CImPdu::GetCommandId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onReceiveData
void FileTransferSocket::onReceiveData(const char* data, UInt32 size)
{
CImPdu* pPdu = 0;
try
{
pPdu = CImPdu::ReadPdu((uchar_t*)data, (uint32_t)size);
PTR_VOID(pPdu);
if (IM_PDU_TYPE_HEARTBEAT == pPdu->GetCommandId() && SID_OTHER == pPdu->GetModuleId())
return;
}
catch (CPduException e)
{
APP_LOG(LOG_ERROR, _T("FileTransferSocket onPacket CPduException serviceId:%d,commandId:%d,errCode:%d")
, e.GetModuleId(), e.GetCommandId(), e.GetErrorCode());
return;
}
catch (...)
{
APP_LOG(LOG_ERROR, _T("FileTransferSocket onPacket unknown exception"));
return;
}
UInt16 ncmdid = pPdu->GetCommandId();
switch (pPdu->GetCommandId())
{
case CID_FILE_LOGIN_RES:
_fileLoginResponse(pPdu);
break;
case CID_FILE_PULL_DATA_REQ:
_filePullDataReqResponse(pPdu);
break;
case CID_FILE_PULL_DATA_RSP:
_filePullDataRspResponse(pPdu);
break;
case CID_FILE_STATE:
_fileState(pPdu);
default:
break;
}
delete pPdu;
pPdu = 0;
}
示例2: login
uint32_t ClientConn::login(const string &strName, const string &strPass)
{
CImPdu cPdu;
IM::Login::IMLoginReq msg;
msg.set_user_name(strName);
msg.set_password(strPass);
msg.set_online_status(IM::BaseDefine::USER_STATUS_ONLINE);
msg.set_client_type(IM::BaseDefine::CLIENT_TYPE_WINDOWS);
msg.set_client_version("100.0.0");
cPdu.SetPBMsg(&msg);
cPdu.SetServiceId(IM::BaseDefine::DFFX_SID_LOGIN);
cPdu.SetCommandId(IM::BaseDefine::DFFX_CID_LOGIN_REQ_USERLOGIN);
printf("login %d\n",cPdu.GetCommandId());
uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET);
cPdu.SetSeqNum(nSeqNo);
SendPdu(&cPdu);
return nSeqNo;
}
示例3: _HandleDbRegisterResponse
void CDBServConn::_HandleDbRegisterResponse(CImPdu* pPdu)
{
RUNTIME_TRACE;
IM::Server::IMDbRegRes msgDb;
CHECK_PB_PARSE_MSG(msgDb.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength()));
string login_name = msgDb.user_name();
CImUser* pImUser = CImUserManager::GetInstance()->GetImUserByLoginName(login_name);
if (!pImUser) {
log("ImUser for user_name=%s not exist", login_name.c_str());
return;
}
CDbAttachData attach_data((uchar_t*)msgDb.attach_data().c_str(), msgDb.attach_data().length());
auto pMsgConn = pImUser->GetUnValidateMsgConn(attach_data.GetHandle());
if (!pMsgConn || pMsgConn->IsOpen()) {
log("no such conn, user_name=%s", login_name.c_str());
return;
}
IM::BaseDefine::UserInfo user_info = msgDb.user_info();
uint32_t user_id = user_info.user_id();
pImUser->SetUserId(user_id);
pImUser->SetNickName(user_info.user_nick_name());
pImUser->SetValidated();
CImUserManager::GetInstance()->AddImUserById(user_id, pImUser);
log("user_name: %s, uid: %d", login_name.c_str(), user_id);
pMsgConn->SetUserId(user_id);
pMsgConn->SetOpen();
pMsgConn->SendUserStatusUpdate(IM::BaseDefine::USER_STATUS_ONLINE);
pImUser->ValidateMsgConn(pMsgConn->GetHandle(), pMsgConn);
IM::Login::IMRegisterRes msgRes;
msgRes.set_user_name(login_name);
msgRes.set_server_time(time(NULL));
msgRes.set_result_code((IM::BaseDefine::ResultType)msgDb.result_code());
msgRes.set_online_status((IM::BaseDefine::UserStatType)pMsgConn->GetOnlineStatus());
msgRes.set_result_string(msgDb.result_string());
IM::BaseDefine::UserInfo* user_info_tmp = msgRes.mutable_user_info();
user_info_tmp->set_user_id(user_info.user_id());
user_info_tmp->set_user_gender(user_info.user_gender());
user_info_tmp->set_user_nick_name(user_info.user_nick_name());
user_info_tmp->set_avatar_url(user_info.avatar_url());
user_info_tmp->set_department_id(user_info.department_id());
user_info_tmp->set_email(user_info.email());
user_info_tmp->set_user_real_name(user_info.user_real_name());
user_info_tmp->set_user_tel(user_info.user_tel());
user_info_tmp->set_user_domain(user_info.user_domain());
user_info_tmp->set_status(user_info.status());
CImPdu pdu;
pdu.SetPBMsg(&msgRes);
pdu.SetServiceId(SID_LOGIN);
pdu.SetCommandId(CID_LOGIN_RES_USERREG);
pdu.SetSeqNum(pPdu->GetSeqNum());
pMsgConn->SendPdu(&pdu);
log("send pdu command id = %d", pdu.GetCommandId());
if (msgDb.result_code())
pMsgConn->Close();
}