diff options
Finished HG Service Store. Not fully functional because of problems with asset.ID insisting on being a UUID string.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | 66 |
1 files changed, 30 insertions, 36 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index e659ad1..b6b2172 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | |||
@@ -120,25 +120,30 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
120 | return null; | 120 | return null; |
121 | } | 121 | } |
122 | 122 | ||
123 | private bool PostAsset(GridAssetClient asscli, UUID assetID, bool isTexture) | 123 | private bool PostAsset(string url, AssetBase asset) |
124 | { | 124 | { |
125 | AssetBase asset1; | 125 | if (asset != null) |
126 | //m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out asset1); | ||
127 | asset1 = m_scene.CommsManager.AssetCache.GetAsset(assetID, isTexture); | ||
128 | |||
129 | if (asset1 != null) | ||
130 | { | 126 | { |
131 | // See long comment in AssetCache.AddAsset | 127 | // See long comment in AssetCache.AddAsset |
132 | if (!asset1.Temporary || asset1.Local) | 128 | if (!asset.Temporary || asset.Local) |
133 | { | 129 | { |
134 | // The asset cache returns instances of subclasses of AssetBase: | 130 | // We need to copy the asset into a new asset, because |
135 | // TextureImage or AssetInfo. So in passing them to the remote | 131 | // we need to set its ID to be URL+UUID, so that the |
136 | // server we first need to convert this to instances of AssetBase, | 132 | // HGAssetService dispatches it to the remote grid. |
137 | // which is the serializable class for assets. | 133 | // It's not pretty, but the best that can be done while |
138 | AssetBase asset = new AssetBase(); | 134 | // not having a global naming infrastructure |
139 | Copy(asset1, asset); | 135 | AssetBase asset1 = new AssetBase(); |
140 | 136 | Copy(asset, asset1); | |
141 | asscli.StoreAsset(asset); | 137 | try |
138 | { | ||
139 | asset1.ID = url + "/" + asset.ID; | ||
140 | } | ||
141 | catch | ||
142 | { | ||
143 | m_log.Warn("[HGScene]: This won't work until Melanie kills a few more dragons"); | ||
144 | } | ||
145 | |||
146 | m_scene.AssetService.Store(asset1); | ||
142 | } | 147 | } |
143 | return true; | 148 | return true; |
144 | } | 149 | } |
@@ -315,46 +320,35 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
315 | { | 320 | { |
316 | if (!IsLocalUser(ownerID)) | 321 | if (!IsLocalUser(ownerID)) |
317 | { | 322 | { |
318 | // Post the item from the local AssetCache ontp the remote asset server | 323 | // Post the item from the local AssetCache onto the remote asset server |
319 | // and place an entry in m_assetMap | 324 | // and place an entry in m_assetMap |
320 | 325 | ||
321 | GridAssetClient asscli = null; | ||
322 | string userAssetURL = UserAssetURL(ownerID); | 326 | string userAssetURL = UserAssetURL(ownerID); |
323 | if (userAssetURL != null) | 327 | if (userAssetURL != null) |
324 | { | 328 | { |
325 | m_assetServers.TryGetValue(userAssetURL, out asscli); | ||
326 | if (asscli == null) | ||
327 | { | ||
328 | m_log.Debug("[HGScene]: Starting new GridAssetClient for " + userAssetURL); | ||
329 | asscli = new GridAssetClient(userAssetURL); | ||
330 | asscli.SetReceiver(m_scene.CommsManager.AssetCache); // Straight to the asset cache! | ||
331 | m_assetServers.Add(userAssetURL, asscli); | ||
332 | } | ||
333 | m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); | 329 | m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); |
334 | AssetBase ass1 = null; | 330 | AssetBase ass1 = m_scene.AssetService.Get(assetID.ToString()); |
335 | m_scene.CommsManager.AssetCache.TryGetCachedAsset(assetID, out ass1); | ||
336 | if (ass1 != null) | 331 | if (ass1 != null) |
337 | { | 332 | { |
338 | bool success = PostAsset(asscli, assetID, (ass1.Type == (sbyte)AssetType.Texture)); | 333 | bool success = PostAsset(userAssetURL, ass1); |
339 | 334 | ||
340 | // Now the inside | 335 | // Now the inside |
341 | Dictionary<UUID, bool> ids = SniffUUIDs(assetID); | 336 | Dictionary<UUID, bool> ids = SniffUUIDs(assetID); |
342 | Dump(ids); | 337 | Dump(ids); |
343 | foreach (KeyValuePair<UUID, bool> kvp in ids) | 338 | foreach (KeyValuePair<UUID, bool> kvp in ids) |
344 | PostAsset(asscli, kvp.Key, kvp.Value); | ||
345 | |||
346 | if (success) | ||
347 | { | 339 | { |
348 | m_log.Debug("[HGScene]: Successfully posted item to remote asset server " + userAssetURL); | 340 | ass1 = m_scene.AssetService.Get(kvp.Key.ToString()); |
349 | if (!m_assetMap.ContainsKey(assetID)) | 341 | PostAsset(userAssetURL, ass1); |
350 | m_assetMap.Add(assetID, asscli); | ||
351 | } | 342 | } |
343 | |||
344 | if (success) | ||
345 | m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL); | ||
352 | else | 346 | else |
353 | m_log.Warn("[HGScene]: Could not post asset to remote asset server " + userAssetURL); | 347 | m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL); |
354 | 348 | ||
355 | } | 349 | } |
356 | else | 350 | else |
357 | m_log.Debug("[HGScene]: Something wrong with asset"); | 351 | m_log.Debug("[HGScene]: Something wrong with asset, it could not be found"); |
358 | } | 352 | } |
359 | else | 353 | else |
360 | m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); | 354 | m_log.Warn("[HGScene]: Unable to locate foreign user's asset server"); |