void UDPAssetProvider::HandleTextureTimeouts(boost::shared_ptr<ProtocolUtilities::ProtocolModuleInterface> net, f64 frametime) { UDPAssetTransferMap::iterator i = texture_transfers_.begin(); std::vector<RexUUID> erase_tex; while(i != texture_transfers_.end()) { UDPAssetTransfer& transfer = i->second; if (!transfer.Ready()) { transfer.AddTime(frametime); if (transfer.GetTime() > asset_timeout_) { RexUUID asset_uuid(transfer.GetAssetId()); AssetModule::LogInfo("Texture transfer " + transfer.GetAssetId() + " timed out."); // Send cancel message const ProtocolUtilities::ClientParameters& client = net->GetClientParameters(); ProtocolUtilities::NetOutMessage *m = net->StartMessageBuilding(RexNetMsgRequestImage); assert(m); m->AddUUID(client.agentID); m->AddUUID(client.sessionID); m->SetVariableBlockCount(1); m->AddUUID(asset_uuid); // Image UUID m->AddS8(-1); // Discard level, -1 = cancel m->AddF32(0.0); // Download priority, 0 = cancel m->AddU32(0); // Starting packet m->AddU8(RexIT_Normal); // Image type m->MarkReliable(); net->FinishMessageBuilding(m); // Send transfer canceled event SendAssetCanceled(transfer); erase_tex.push_back(i->first); } } ++i; } for(int j = 0; j < erase_tex.size(); ++j) texture_transfers_.erase(erase_tex[j]); }
void UDPAssetProvider::RequestOtherAsset(boost::shared_ptr<ProtocolUtilities::ProtocolModuleInterface> net, const RexUUID& asset_id, uint asset_type, const RequestTagVector& tags) { // If request already exists, just append the new tag(s) std::string asset_id_str = asset_id.ToString(); UDPAssetTransfer* transfer = GetTransfer(asset_id_str); if (transfer) { transfer->InsertTags(tags); return; } RexUUID transfer_id; transfer_id.Random(); UDPAssetTransfer new_transfer; new_transfer.SetAssetId(asset_id_str); new_transfer.SetAssetType(asset_type); new_transfer.InsertTags(tags); asset_transfers_[transfer_id] = new_transfer; AssetModule::LogDebug("Requesting asset " + asset_id_str); ProtocolUtilities::NetOutMessage *m = net->StartMessageBuilding(RexNetMsgTransferRequest); assert(m); m->AddUUID(transfer_id); // Transfer ID m->AddS32(RexAC_Asset); // Asset channel type m->AddS32(RexAS_Asset); // Asset source type m->AddF32(100.0); // Download priority u8 asset_info[20]; // Asset info block with UUID and type memcpy(&asset_info[0], &asset_id.data, 16); memcpy(&asset_info[16], &asset_type, 4); m->AddBuffer(20, asset_info); m->MarkReliable(); net->FinishMessageBuilding(m); return; }
void UDPAssetProvider::RequestTexture(boost::shared_ptr<ProtocolUtilities::ProtocolModuleInterface> net, const RexUUID& asset_id, const RequestTagVector& tags) { // If request already exists, just append the new tag(s) std::string asset_id_str = asset_id.ToString(); UDPAssetTransfer* transfer = GetTransfer(asset_id_str); if (transfer) { transfer->InsertTags(tags); return; } const ProtocolUtilities::ClientParameters& client = net->GetClientParameters(); UDPAssetTransfer new_transfer; new_transfer.SetAssetId(asset_id.ToString()); new_transfer.SetAssetType(RexAT_Texture); new_transfer.InsertTags(tags); texture_transfers_[asset_id] = new_transfer; AssetModule::LogDebug("Requesting texture " + asset_id.ToString()); ProtocolUtilities::NetOutMessage *m = net->StartMessageBuilding(RexNetMsgRequestImage); assert(m); m->AddUUID(client.agentID); m->AddUUID(client.sessionID); m->SetVariableBlockCount(1); m->AddUUID(asset_id); // Image UUID m->AddS8(0); // Discard level m->AddF32(100.0); // Download priority m->AddU32(0); // Starting packet m->AddU8(RexIT_Normal); // Image type m->MarkReliable(); net->FinishMessageBuilding(m); }
void UDPAssetProvider::HandleAssetTimeouts(boost::shared_ptr<ProtocolUtilities::ProtocolModuleInterface> net, f64 frametime) { UDPAssetTransferMap::iterator i = asset_transfers_.begin(); std::vector<RexUUID> erase_asset; while(i != asset_transfers_.end()) { bool erased = false; UDPAssetTransfer& transfer = i->second; if (!transfer.Ready()) { transfer.AddTime(frametime); if (transfer.GetTime() > asset_timeout_) { AssetModule::LogInfo("Asset transfer " + transfer.GetAssetId() + " timed out."); // Send cancel message ProtocolUtilities::NetOutMessage *m = net->StartMessageBuilding(RexNetMsgTransferAbort); assert(m); m->AddUUID(i->first); // Transfer ID m->AddS32(RexAC_Asset); // Asset channel type m->MarkReliable(); net->FinishMessageBuilding(m); // Send transfer canceled event SendAssetCanceled(transfer); erase_asset.push_back(i->first); } } ++i; } for (int j = 0; j < erase_asset.size(); ++j) asset_transfers_.erase(erase_asset[j]); }