void AbiCollab::_restartAsMaster() { UT_DEBUGMSG(("AbiCollab::_restartAsMaster()\n")); m_Import.masterInit(); m_Export.masterInit(); // the session controller will never have to revert individual changerecords, // so we can re-enable changerecord coalescing // FIXME: enable this //pDoc->setCoalescingMask(true); // inform everyone that we can restart this session SessionReconnectAckPacket srap(m_sId, m_pDoc->getDocUUIDString(), m_pDoc->getCRNumber()); for (std::map<BuddyPtr, std::string>::iterator it = m_vCollaborators.begin(); it != m_vCollaborators.end(); it++) { BuddyPtr pBuddy = (*it).first; UT_continue_if_fail(pBuddy); AccountHandler* pHandler = pBuddy->getHandler(); UT_continue_if_fail(pHandler); pHandler->send(&srap, pBuddy); } // we're the master now! m_eTakeoveState = STS_NONE; _pushOutgoingQueue(); }
/*! * Send this packet. Note, the specified packet does still belong to the calling class. * So if we want to store it (for masking), we HAVE to clone it first */ void AbiCollab::push(SessionPacket* pPacket) { UT_DEBUGMSG(("AbiCollab::push()\n")); UT_return_if_fail(pPacket); if (m_bIsReverting) { UT_DEBUGMSG(("This packet was generated by a local revert triggerd in the import; dropping on the floor!\n")); return; } if (m_bExportMasked) { m_vecMaskedPackets.push_back(static_cast<SessionPacket*>(pPacket->clone())); // TODO: make this a shared ptr, so we don't need to clone the packet return; } if (!isLocallyControlled() && m_eTakeoveState != STS_NONE) { // TODO: revert ack packets should still go to old master // (or be dropped on the floor, as he probably is not even around anymore) UT_DEBUGMSG(("We're in the middle of a session takeover; holding on to the packet until the new master is ready")); m_vOutgoingQueue.push_back(static_cast<SessionPacket*>(pPacket->clone())); // TODO: make this a shared ptr, so we don't need to clone the packet return; } // record if (m_pRecorder) m_pRecorder->storeOutgoing( const_cast<const SessionPacket*>( pPacket ) ); // TODO: this could go in the session manager UT_DEBUGMSG(("Pusing packet to %d collaborators\n", m_vCollaborators.size())); for (std::map<BuddyPtr, std::string>::iterator it = m_vCollaborators.begin(); it != m_vCollaborators.end(); it++) { BuddyPtr pCollaborator = (*it).first; UT_continue_if_fail(pCollaborator); UT_DEBUGMSG(("Pushing packet to collaborator with descriptor: %s\n", pCollaborator->getDescriptor(true).utf8_str())); AccountHandler* pHandler = pCollaborator->getHandler(); UT_continue_if_fail(pHandler); // overwrite remote revision for this collaborator _fillRemoteRev(pPacket, pCollaborator); // send! bool res = pHandler->send(pPacket, pCollaborator); if (!res) { UT_DEBUGMSG(("Error sending a packet!\n")); } } }
bool AbiCollab::push(SessionPacket* pPacket, BuddyPtr collaborator) { UT_return_val_if_fail(pPacket, false); UT_return_val_if_fail(collaborator, false); AccountHandler* pHandler = collaborator->getHandler(); UT_return_val_if_fail(pHandler, false); // record if (m_pRecorder) m_pRecorder->storeOutgoing(const_cast<const SessionPacket*>( pPacket ), collaborator); // overwrite remote revision for this collaborator _fillRemoteRev(pPacket, collaborator); // send! bool res = pHandler->send(pPacket, collaborator); if (!res) { UT_DEBUGMSG(("Error sending a packet to collaborator %s!\n", collaborator->getDescription().utf8_str())); } return res; }