aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authordiva2009-05-17 01:38:43 +0000
committerdiva2009-05-17 01:38:43 +0000
commitaac8ca041170f6d1d648c6c5244dc3dfad428587 (patch)
tree190873d49a54f7462190331344aa308d8b6eb15f /OpenSim/Region/Framework
parentSend the owner name, not the client name on SendDialog. (diff)
downloadopensim-SC_OLD-aac8ca041170f6d1d648c6c5244dc3dfad428587.zip
opensim-SC_OLD-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.gz
opensim-SC_OLD-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.bz2
opensim-SC_OLD-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.xz
HG asset transfers starting to work -- GETs only for now.
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs76
1 files changed, 14 insertions, 62 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 985ee98..e659ad1 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -108,50 +108,16 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
108 return m_assetMap.ContainsKey(uuid); 108 return m_assetMap.ContainsKey(uuid);
109 } 109 }
110 110
111 private bool FetchAsset(GridAssetClient asscli, UUID assetID, bool isTexture) 111 private AssetBase FetchAsset(string url, UUID assetID, bool isTexture)
112 { 112 {
113 // I'm not going over 3 seconds since this will be blocking processing of all the other inbound 113 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
114 // packets from the client.
115 int pollPeriod = 200;
116 int maxPolls = 15;
117 114
118 AssetBase asset; 115 if (asset != null)
119
120 // Maybe it came late, and it's already here. Check first.
121 if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset))
122 { 116 {
123 m_log.Debug("[HGScene]: Asset already in asset cache. " + assetID); 117 m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID);
124 return true; 118 return asset;
125 } 119 }
126 120 return null;
127
128 asscli.RequestAsset(assetID, isTexture);
129
130 do
131 {
132 Thread.Sleep(pollPeriod);
133
134 if (m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset) && (asset != null))
135 {
136 m_log.Debug("[HGScene]: Asset made it to asset cache. " + asset.Name + " " + assetID);
137 // I think I need to store it in the asset DB too.
138 // For now, let me just do it for textures and scripts
139 if (((AssetType)asset.Type == AssetType.Texture) ||
140 ((AssetType)asset.Type == AssetType.LSLBytecode) ||
141 ((AssetType)asset.Type == AssetType.LSLText))
142 {
143 AssetBase asset1 = new AssetBase();
144 Copy(asset, asset1);
145 m_scene.CommsManager.AssetCache.AssetServer.StoreAsset(asset1);
146 }
147 return true;
148 }
149 } while (--maxPolls > 0);
150
151 m_log.WarnFormat("[HGScene]: {0} {1} was not received before the retrieval timeout was reached",
152 isTexture ? "texture" : "asset", assetID.ToString());
153
154 return false;
155 } 121 }
156 122
157 private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture) 123 private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture)
@@ -291,39 +257,25 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
291 257
292 public void Get(UUID assetID, UUID ownerID) 258 public void Get(UUID assetID, UUID ownerID)
293 { 259 {
294 if (!IsInAssetMap(assetID) && !IsLocalUser(ownerID)) 260 if (!IsLocalUser(ownerID))
295 { 261 {
296 // Get the item from the remote asset server onto the local AssetCache 262 // Get the item from the remote asset server onto the local AssetCache
297 // and place an entry in m_assetMap 263 // and place an entry in m_assetMap
298 264
299 GridAssetClient asscli = null;
300 string userAssetURL = UserAssetURL(ownerID); 265 string userAssetURL = UserAssetURL(ownerID);
301 if (userAssetURL != null) 266 if (userAssetURL != null)
302 { 267 {
303 m_assetServers.TryGetValue(userAssetURL, out asscli);
304 if (asscli == null)
305 {
306 m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL);
307 asscli = new GridAssetClient(userAssetURL);
308 asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache!
309 m_assetServers.Add(userAssetURL, asscli);
310 asscli.Start();
311 }
312
313 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); 268 m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL);
314 bool success = FetchAsset(asscli, assetID, false); // asscli.RequestAsset(item.ItemID, false); 269 AssetBase asset = FetchAsset(userAssetURL, assetID, false);
315 270
316 // OK, now fetch the inside. 271 if (asset != null)
317 Dictionary<UUID, bool> ids = SniffUUIDs(assetID);
318 Dump(ids);
319 foreach (KeyValuePair<UUID, bool> kvp in ids)
320 FetchAsset(asscli, kvp.Key, kvp.Value);
321
322
323 if (success)
324 { 272 {
325 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); 273 m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
326 m_assetMap.Add(assetID, asscli); 274 // OK, now fetch the inside.
275 Dictionary<UUID, bool> ids = SniffUUIDs(asset);
276 Dump(ids);
277 foreach (KeyValuePair<UUID, bool> kvp in ids)
278 FetchAsset(userAssetURL, kvp.Key, kvp.Value);
327 } 279 }
328 else 280 else
329 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); 281 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);