//"#COMMAND#type=fileRequest,packId=xxx" void CMsgSessionManager::SendCmd(tstring strDestAccount, ECmdType eType, tstring& strParas) { //check if session exist; MessageSession* pDestSesion = NULL; MapAccount2Sessions::iterator itFind = m_mapAccount2Sessions.find(strDestAccount); if (itFind != m_mapAccount2Sessions.end()) { pDestSesion = itFind->second; } if (NULL == pDestSesion) { JID jid(strDestAccount); pDestSesion = new MessageSession(j, jid); if (NULL != pDestSesion) { pDestSesion->registerMessageHandler(this); m_mapAccount2Sessions.insert(make_pair(strDestAccount, pDestSesion)); } } if (NULL != pDestSesion) { pDestSesion->send(strParas.c_str()); } }
MessageSession* Core::create_session(const string bare){ MessageSession* session = new MessageSession(ptr_cpclient->get_client(),bare); //session->setThreadID("session_" + bare); ptr_cpclient->store_session(session); ptr_cpclient->register_session(session); session->registerMessageHandler(this); write_string("A new chat session is created with JID: " + session->target().full()); return session; }
void CMsgSessionManager::SendMsg(tstring strDestAccount, tstring& strMsg) { //check if session exist; MessageSession* pDestSesion = NULL; MapAccount2Sessions::iterator itFind = m_mapAccount2Sessions.find(strDestAccount); if (itFind != m_mapAccount2Sessions.end()) { pDestSesion = itFind->second; } if (NULL == pDestSesion) { JID jid(strDestAccount); pDestSesion = new MessageSession(j, jid); if (NULL != pDestSesion) { pDestSesion->registerMessageHandler(this); m_mapAccount2Sessions.insert(make_pair(strDestAccount, pDestSesion)); } } if (NULL != pDestSesion) { MapMsgEventFilters::iterator itMsgFiler = m_mapDest2MsgEventFilters.find(strDestAccount); if (itMsgFiler != m_mapDest2MsgEventFilters.end()) { MessageEventFilter*pFilter = itMsgFiler->second; if (NULL != pFilter) { pFilter->raiseMessageEvent(MessageEventComposing); } } MapChatStateFilters::iterator itStatefilter = m_mapDest2ChatStateFilters.find(strDestAccount); if (itStatefilter != m_mapDest2ChatStateFilters.end()) { ChatStateFilter* pFilter = itStatefilter->second; if (NULL != pFilter) { pFilter->setChatState(ChatStateComposing); } } tstring strOut; CChineseCode::GB2312ToUTF_8(strOut, (char*)strMsg.c_str(), strMsg.size()); pDestSesion->send(/*strMsg*/strOut, ""); } }