コード例 #1
0
ファイル: Data.cpp プロジェクト: JarodCoding/RealTimeStars
		void Node::syncNode(std::vector<ExtensionTypeID>& sortedExtensionsOfInterest){
			syncAll();
			size_t i = 0;
			auto extensionIterator = extensions.begin();
			if(sortedExtensionsOfInterest[i]==extensionIterator->first)extensionIterator->second->access()->syncAll();
			while(i <sortedExtensionsOfInterest.size() && extensionIterator!=extensions.end()){
				if(sortedExtensionsOfInterest[i]==extensionIterator->first)extensionIterator->second->access()->syncAll();
				while(i <sortedExtensionsOfInterest.size()&&sortedExtensionsOfInterest[i]<extensionIterator->first){i++;}
				if(i >= sortedExtensionsOfInterest.size())continue;
				if(sortedExtensionsOfInterest[i]==extensionIterator->first)extensionIterator->second->access()->syncAll();
				while(extensionIterator!=extensions.end()&&extensionIterator->first<sortedExtensionsOfInterest[i]){extensionIterator++;}
			}
			for(auto childIterator = children.begin();childIterator != children.end();childIterator++){
				childIterator->second->access().syncNode(sortedExtensionsOfInterest);
			}
		}
コード例 #2
0
ファイル: ProfileTransport.hpp プロジェクト: aiyi/kaa
 virtual void sync() {
     syncAll();
 }
コード例 #3
0
 virtual void onProfileResync() { syncAll(); }
コード例 #4
0
void DefaultOperationTcpChannel::onKaaSync(const KaaSyncResponse& message)
{
    KAA_LOG_DEBUG(boost::format("Channel [%1%]. KaaSync response received") % getId());
    const auto& encodedResponse = message.getPayload();

    std::string decodedResponse;

    try {
        decodedResponse = encDec_->decodeData(encodedResponse.data(), encodedResponse.size());
    } catch (const std::exception& e) {
        KAA_LOG_ERROR(boost::format("Channel [%1%] unable to decode data: %2%")
                                                                        % getId()
                                                                        % e.what());

        onServerFailed();
        return;
    }

    auto returnCode = demultiplexer_->processResponse(
                                            std::vector<std::uint8_t>(reinterpret_cast<const std::uint8_t *>(decodedResponse.data()),
                                                                      reinterpret_cast<const std::uint8_t *>(decodedResponse.data() + decodedResponse.size())));

    if (returnCode == DemultiplexerReturnCode::REDIRECT) {
        throw TransportRedirectException(boost::format("Channel [%1%] received REDIRECT response") % getId());
    } else if (returnCode == DemultiplexerReturnCode::FAILURE) {
        onServerFailed();
        return;
    }

    KAA_MUTEX_LOCKING("channelGuard_");
    KAA_MUTEX_UNIQUE_DECLARE(lock, channelGuard_);
    KAA_MUTEX_LOCKED("channelGuard_");

    if (!isFirstResponseReceived_) {
        KAA_LOG_INFO(boost::format("Channel [%1%] received first response") % getId());
        connAckTimer_.cancel();
        isFirstResponseReceived_ = true;
    }

    if (isPendingSyncRequest_) {
        isPendingSyncRequest_ = false;
        ackTypes_.clear();

        KAA_MUTEX_UNLOCKING("channelGuard_");
        KAA_UNLOCK(lock);
        KAA_MUTEX_UNLOCKED("channelGuard_");

        KAA_LOG_INFO(boost::format("Channel [%1%] has pending request. Starting SYNC...") % getId());

        syncAll();
    } else if (!ackTypes_.empty()) {
        KAA_LOG_INFO(boost::format("Channel [%1%] has %2% pending ACK requests. Starting SYNC...")
                                                                                    % getId()
                                                                                    % ackTypes_.size());

        auto ackTypesCopy = ackTypes_;
        ackTypes_.clear();

        KAA_MUTEX_UNLOCKING("channelGuard_");
        KAA_UNLOCK(lock);
        KAA_MUTEX_UNLOCKED("channelGuard_");

        if (ackTypesCopy.size() > 1) {
            syncAll();
        } else {
            sync(*ackTypesCopy.begin());
        }
    }
}