CImPdu sendMessage(uint32_t nFromId, uint32_t nToId, const string& strMsgData) { CImPdu cPdu; IM::Message::IMMsgData msg; msg.set_from_user_id(nFromId); msg.set_to_session_id(nToId); msg.set_msg_id(0); msg.set_create_time(time(NULL)); msg.set_msg_type(IM::BaseDefine::MSG_TYPE_SINGLE_TEXT); msg.set_msg_data(strMsgData); cPdu.SetPBMsg(&msg); cPdu.SetServiceId(IM::BaseDefine::SID_MSG); cPdu.SetCommandId(IM::BaseDefine::CID_MSG_DATA); cPdu.SetSeqNum(2); return cPdu; }
uint32_t ClientConn::sendMessage(uint32_t nFromId, uint32_t nToId, IM::BaseDefine::MsgType nType, const string& strMsgData) { CImPdu cPdu; IM::Message::IMMsgData msg; msg.set_from_user_id(nFromId); msg.set_to_session_id(nToId); msg.set_msg_id(0); msg.set_create_time(time(NULL)); msg.set_msg_type(nType); msg.set_msg_data(strMsgData); cPdu.SetPBMsg(&msg); cPdu.SetServiceId(IM::BaseDefine::SID_MSG); cPdu.SetCommandId(IM::BaseDefine::CID_MSG_DATA); uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET); cPdu.SetSeqNum(nSeqNo); SendPdu(&cPdu); return nSeqNo; }
uint32_t ClientConn::sendMessage(uint32_t nFromId, uint32_t nToId, IM::BaseDefine::MsgType nType, const string& strMsgData) { CImPdu cPdu; IM::Message::IMMsgData msg; msg.set_from_user_id(nFromId); msg.set_to_session_id(nToId); msg.set_msg_id(0); msg.set_create_time(time(NULL)); msg.set_msg_type(nType); //msg.set_msg_data(strMsgData); //EncryptMsg char * pOutData=NULL; uint32_t nOutLen = 0; int retCode = EncryptMsg( strMsgData.c_str(), strMsgData.length(), &pOutData, nOutLen); if (retCode == 0 && nOutLen > 0 && pOutData != 0) { msg.set_msg_data( pOutData, nOutLen); //delete pOutData; Free(pOutData); pOutData = NULL; } else { log("EncryptMsg error:%s\n", strMsgData.c_str()); msg.set_msg_data( strMsgData); } cPdu.SetPBMsg(&msg); cPdu.SetServiceId(IM::BaseDefine::DFFX_SID_MSG); cPdu.SetCommandId(IM::BaseDefine::DFFX_CID_MSG_DATA); uint32_t nSeqNo = m_pSeqAlloctor->getSeq(ALLOCTOR_PACKET); cPdu.SetSeqNum(nSeqNo); SendPdu(&cPdu); return nSeqNo; }