void MRTTransferSession::OnTypeConn(const std::string& str) { #if DEF_PROTO pms::ConnMsg c_msg; if (!c_msg.ParseFromString(str)) { LE("OnTypeConn c_msg.ParseFromString error\n"); } LI("OnTypeConn connmsg--->:\n"); //c_msg.PrintDebugString(); if ((c_msg.conn_tag() == pms::EConnTag::THELLO)) { // when ME connector to other: if (c_msg.transferid().length()>0) { m_transferSessId = c_msg.transferid(); { MRTConnManager::ModuleInfo* pmi = new MRTConnManager::ModuleInfo(); if (pmi) { pmi->flag = 1; pmi->othModuleType = c_msg.tr_module(); pmi->othModuleId = m_transferSessId; pmi->pModule = this; //bind session and transfer id MRTConnManager::Instance().AddModuleInfo(pmi, m_transferSessId); //store which moudle connect to this connector MRTConnManager::Instance().AddTypeModuleSession(c_msg.tr_module(), c_msg.moduleid(), m_transferSessId); LI("store other moduleid:%s, transfersessionid:%s\n", c_msg.moduleid().c_str(), m_transferSessId.c_str()); } else { LE("new ModuleInfo error\n"); } } pms::TransferMsg t_msg; c_msg.set_tr_module(pms::ETransferModule::MMEETING); c_msg.set_conn_tag(pms::EConnTag::THELLOHI); c_msg.set_transferid(m_transferSessId); //send self module id to other c_msg.set_moduleid(MRTConnManager::Instance().MeetingId()); t_msg.set_type(pms::ETransferType::TCONN); t_msg.set_flag(pms::ETransferFlag::FNEEDACK); t_msg.set_priority(pms::ETransferPriority::PHIGH); t_msg.set_content(c_msg.SerializeAsString()); std::string s = t_msg.SerializeAsString(); SendTransferData(s.c_str(), (int)s.length()); } else { LE("Connection id:%s error!!!\n", c_msg.transferid().c_str()); } } #else LE("not define DEF_PROTO\n") #endif }
void LRTGroupSession::KeepAlive() { #if DEF_PROTO pms::TransferMsg t_msg; pms::ConnMsg c_msg; c_msg.set_tr_module(pms::ETransferModule::MLIVE); c_msg.set_conn_tag(pms::EConnTag::TKEEPALIVE); t_msg.set_type(pms::ETransferType::TCONN); t_msg.set_flag(pms::ETransferFlag::FNOACK); t_msg.set_priority(pms::ETransferPriority::PNORMAL); t_msg.set_content(c_msg.SerializeAsString()); std::string s = t_msg.SerializeAsString(); SendTransferData(s.c_str(), (int)s.length()); #else LE("not define DEF_PROTO\n"); #endif }
void MRTTransferSession::EstablishConnection() { #if DEF_PROTO pms::TransferMsg t_msg; pms::ConnMsg c_msg; c_msg.set_tr_module(pms::ETransferModule::MMEETING); c_msg.set_conn_tag(pms::EConnTag::THI); t_msg.set_type(pms::ETransferType::TCONN); t_msg.set_flag(pms::ETransferFlag::FNEEDACK); t_msg.set_priority(pms::ETransferPriority::PHIGH); t_msg.set_content(c_msg.SerializeAsString()); std::string s = t_msg.SerializeAsString(); SendTransferData(s.c_str(), (int)s.length()); #else LE("not define DEF_PROTO\n") #endif }
void CRTTransferSession::TransferMsg(const std::string& msg) { TRANSFERMSG t_trmsg; TRANSMSG t_msg; t_msg._flag = 0; t_msg._touser = ""; t_msg._connector = CRTConnManager::Instance().ConnectorId(); t_msg._content = msg; t_trmsg._action = TRANSFERACTION::req; t_trmsg._fmodule = TRANSFERMODULE::mconnector; t_trmsg._type = TRANSFERTYPE::trans; t_trmsg._trans_seq = GenericTransSeq(); t_trmsg._trans_seq_ack = 0; t_trmsg._valid = 1; t_trmsg._content = t_msg.ToJson(); const std::string s = t_trmsg.ToJson(); SendTransferData(s.c_str(), (int)s.length()); }
void DRTTransferSession::KeepAlive() { TRANSFERMSG t_msg; CONNMSG c_msg; t_msg._action = TRANSFERACTION::req; t_msg._fmodule = TRANSFERMODULE::mmsgqueue; t_msg._type = TRANSFERTYPE::conn; t_msg._trans_seq = GenericTransSeq(); t_msg._trans_seq_ack = 0; t_msg._valid = 1; c_msg._tag = CONNTAG::co_keepalive; c_msg._msg = "1"; c_msg._id = ""; c_msg._msgid = ""; c_msg._moduleid = ""; t_msg._content = c_msg.ToJson(); std::string s = t_msg.ToJson(); SendTransferData(s.c_str(), (int)s.length()); }
void CRTTransferSession::EstablishConnection() { TRANSFERMSG t_msg; CONNMSG c_msg; t_msg._action = TRANSFERACTION::req; t_msg._fmodule = TRANSFERMODULE::mconnector; t_msg._type = TRANSFERTYPE::conn; t_msg._trans_seq = GenericTransSeq(); t_msg._trans_seq_ack = 0; t_msg._valid = 1; c_msg._tag = CONNTAG::co_msg; c_msg._msg = "hello"; c_msg._id = ""; c_msg._msgid = ""; c_msg._moduleid = ""; t_msg._content = c_msg.ToJson(); std::string s = t_msg.ToJson(); SendTransferData(s.c_str(), (int)s.length()); }
void LRTGroupSession::SendTransferData(const std::string& data) { SendTransferData(data.c_str(), data.length()); }
void CRTTransferSession::OnTypeConn(TRANSFERMODULE fmodule, const std::string& str) { CONNMSG c_msg; std::string err; c_msg.GetMsg(str, err); if (err.length()>0) { LE("CRTTransferSession::OnTypeConn GetMsg err:%s\n", err.c_str()); return; } if ((c_msg._tag == CONNTAG::co_msg) && c_msg._msg.compare("hello") == 0) { // when other connect to ME: // generate TransferSessionId // send self ModuleId and TransferSessionId to other TRANSFERMSG t_msg; std::string trid; GenericSessionId(trid); m_transferSessId = trid; t_msg._action = TRANSFERACTION::req; //this is for transfer t_msg._fmodule = TRANSFERMODULE::mconnector; t_msg._type = TRANSFERTYPE::conn; t_msg._trans_seq = GenericTransSeq(); t_msg._trans_seq_ack = 0; t_msg._valid = 1; c_msg._tag = CONNTAG::co_id; c_msg._id = trid; //send self connector to other c_msg._moduleid = CRTConnManager::Instance().ConnectorId(); t_msg._content = c_msg.ToJson(); std::string s = t_msg.ToJson(); SendTransferData(s.c_str(), (int)s.length()); } else if ((c_msg._tag == CONNTAG::co_msgid) && c_msg._msgid.compare("ok") == 0) { // when other connect to ME: //get other's TransferSessionId and ModuleId if (m_transferSessId.compare(c_msg._id)==0) { CRTConnManager::ModuleInfo* pmi = new CRTConnManager::ModuleInfo(); if (pmi) { pmi->flag = 1; //store other's module type pmi->othModuleType = fmodule; pmi->othModuleId = m_transferSessId; pmi->pModule = this; //bind session and transfer id CRTConnManager::Instance().AddModuleInfo(pmi, m_transferSessId); //store which moudle connect to this connector //c_msg._moduleid: store other's module id CRTConnManager::Instance().AddTypeModuleSession(fmodule, c_msg._moduleid, m_transferSessId); LI("store the other's module fmodule:%d, id:%s, transfersessid:%s\n", (int)fmodule, c_msg._moduleid.c_str(), c_msg._id.c_str()); } else { LE("new ModuleInfo error!!!\n"); } } } else if (c_msg._tag == CONNTAG::co_keepalive) { this->RTTcp::UpdateTimer(); } else { LE("%s invalid msg tag\n", __FUNCTION__); } }