aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache
diff options
context:
space:
mode:
authorTleiades Hax2007-10-26 11:46:27 +0000
committerTleiades Hax2007-10-26 11:46:27 +0000
commit5e7dba726896fcb84882b53952651742926e6efb (patch)
treea396337e721912fd954e8a66e26d16c375d7bab4 /OpenSim/Framework/Communications/Cache
parentadd my set-eol-style script. Can be run on Linux (diff)
downloadopensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.zip
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.gz
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.bz2
opensim-SC_OLD-5e7dba726896fcb84882b53952651742926e6efb.tar.xz
Very early first implementation of grid based assets.
Run this on a major grid, and weep
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs11
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs36
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs160
3 files changed, 185 insertions, 22 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 271934f..95183ad 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -36,6 +36,7 @@ using libsecondlife.Packets;
36using OpenSim.Framework.Interfaces; 36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types; 37using OpenSim.Framework.Types;
38using OpenSim.Framework.Utilities; 38using OpenSim.Framework.Utilities;
39using OpenSim.Framework.Console;
39 40
40namespace OpenSim.Framework.Communications.Cache 41namespace OpenSim.Framework.Communications.Cache
41{ 42{
@@ -319,17 +320,19 @@ namespace OpenSim.Framework.Communications.Cache
319 320
320 public void AssetNotFound(LLUUID assetID) 321 public void AssetNotFound(LLUUID assetID)
321 { 322 {
322 /*
323 if (this.RequestedTextures.ContainsKey(assetID)) 323 if (this.RequestedTextures.ContainsKey(assetID))
324 { 324 {
325 MainLog.Instance.Warn("ASSET CACHE", "sending image not found for {0}", assetID);
325 AssetRequest req = this.RequestedTextures[assetID]; 326 AssetRequest req = this.RequestedTextures[assetID];
326 ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); 327 ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket();
327 notFound.ImageID.ID = assetID; 328 notFound.ImageID.ID = assetID;
328 req.RequestUser.OutPacket(notFound); 329 req.RequestUser.OutPacket(notFound);
329 //Console.WriteLine("sending image not found for " + assetID);
330
331 this.RequestedTextures.Remove(assetID); 330 this.RequestedTextures.Remove(assetID);
332 }*/ 331 }
332 else
333 {
334 MainLog.Instance.Error("ASSET CACHE", "Cound not send image not found for {0}", assetID);
335 }
333 } 336 }
334 337
335 #region Assets 338 #region Assets
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index a3ec346..53efa16 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -108,23 +108,23 @@ namespace OpenSim.Framework.Communications.Cache
108 public virtual List<AssetBase> GetDefaultAssets() 108 public virtual List<AssetBase> GetDefaultAssets()
109 { 109 {
110 List<AssetBase> assets = new List<AssetBase>(); 110 List<AssetBase> assets = new List<AssetBase>();
111 111 // These assets have been moved into the OpenSimAssetSet.XML file
112 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000001", "Bricks", "bricks.jp2")); 112 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000001", "Bricks", "bricks.jp2"));
113 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000002", "Plywood", "plywood.jp2")); 113 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000002", "Plywood", "plywood.jp2"));
114 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000003", "Rocks", "rocks.jp2")); 114 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000003", "Rocks", "rocks.jp2"));
115 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000004", "Granite", "granite.jp2")); 115 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000004", "Granite", "granite.jp2"));
116 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000005", "Hardwood", "hardwood.jp2")); 116 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000005", "Hardwood", "hardwood.jp2"));
117 assets.Add(CreateImageAsset("00000000-0000-0000-5005-000000000005", "Prim Base Texture", "plywood.jp2")); 117 //assets.Add(CreateImageAsset("00000000-0000-1111-5005-000000000005", "Prim Base Texture", "plywood.jp2"));
118 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000006", "Map Base Texture", "map_base.jp2")); 118 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000006", "Map Base Texture", "map_base.jp2"));
119 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000007", "Map Texture", "map1.jp2")); 119 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000007", "Map Texture", "map1.jp2"));
120 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000010", "Female Body Texture", "femalebody.jp2")); 120 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000010", "Female Body Texture", "femalebody.jp2"));
121 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2")); 121 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000011", "Female Bottom Texture", "femalebottom.jp2"));
122 assets.Add(CreateImageAsset("00000000-0000-0000-9999-000000000012", "Female Face Texture", "femaleface.jp2")); 122 //assets.Add(CreateImageAsset("00000000-0000-1111-9999-000000000012", "Female Face Texture", "femaleface.jp2"));
123 123
124 assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false)); 124 //assets.Add(CreateAsset("77c41e39-38f9-f75a-024e-585989bbabbb", "Skin", "base_skin.dat", false));
125 assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false)); 125 //assets.Add(CreateAsset("66c41e39-38f9-f75a-024e-585989bfab73", "Shape", "base_shape.dat", false));
126 assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false)); 126 //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111110", "Shirt", "newshirt.dat", false));
127 assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false)); 127 //assets.Add(CreateAsset("00000000-38f9-1111-024e-222222111120", "Shirt", "newpants.dat", false));
128 128
129 return assets; 129 return assets;
130 } 130 }
@@ -185,4 +185,4 @@ namespace OpenSim.Framework.Communications.Cache
185 } 185 }
186 } 186 }
187 } 187 }
188} \ No newline at end of file 188}
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
new file mode 100644
index 0000000..fc77431
--- /dev/null
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -0,0 +1,160 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28using System;
29using System.IO;
30using System.Threading;
31using System.Reflection;
32using System.Xml.Serialization;
33
34using libsecondlife;
35
36using Nini.Config;
37using OpenSim.Framework.Console;
38using OpenSim.Framework.Interfaces;
39using OpenSim.Framework.Types;
40using OpenSim.Framework.Utilities;
41using OpenSim.Framework.Communications;
42
43namespace OpenSim.Framework.Communications.Cache
44{
45 public class GridAssetClient : IAssetServer
46 {
47 private string _assetServerUrl;
48 private IAssetReceiver _receiver;
49
50 public GridAssetClient(string serverUrl)
51 {
52 _assetServerUrl = serverUrl;
53 }
54
55 #region IAssetServer Members
56
57 public void SetReceiver(IAssetReceiver receiver)
58 {
59 _receiver = receiver;
60 }
61
62 public void FetchAsset(LLUUID assetID, bool isTexture)
63 {
64 Stream s = null;
65 try
66 {
67
68 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", assetID.ToString());
69
70 RestClient rc = new RestClient(_assetServerUrl);
71 rc.AddResourcePath("assets");
72 rc.AddResourcePath(assetID.ToString());
73 if (isTexture)
74 rc.AddQueryParameter("texture");
75
76 rc.RequestMethod = "GET";
77 s = rc.Request();
78
79 if (s.Length > 0)
80 {
81 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
82 AssetBase asset = (AssetBase)xs.Deserialize(s);
83
84 _receiver.AssetReceived(asset, isTexture);
85 }
86 else
87 {
88 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", assetID.ToString());
89 _receiver.AssetNotFound(assetID);
90 }
91 }
92 catch (Exception e)
93 {
94 MainLog.Instance.Error("ASSETCACHE", e.Message);
95 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
96 }
97 }
98
99 public void UpdateAsset(AssetBase asset)
100 {
101 throw new Exception("The method or operation is not implemented.");
102 }
103
104 public void StoreAndCommitAsset(AssetBase asset)
105 {
106 try
107 {
108 MemoryStream s = new MemoryStream();
109
110 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
111 xs.Serialize(s, asset);
112 RestClient rc = new RestClient(_assetServerUrl);
113 rc.AddResourcePath("assets");
114 rc.RequestMethod = "POST";
115 rc.Request(s);
116 }
117 catch (Exception e)
118 {
119 MainLog.Instance.Error("ASSETS", e.Message);
120 }
121 }
122
123 public void Close()
124 {
125 throw new Exception("The method or operation is not implemented.");
126 }
127
128 public void LoadAsset(AssetBase info, bool image, string filename)
129 {
130 throw new Exception("The method or operation is not implemented.");
131 }
132
133 public System.Collections.Generic.List<AssetBase> GetDefaultAssets()
134 {
135 throw new Exception("The method or operation is not implemented.");
136 }
137
138 public AssetBase CreateImageAsset(string assetIdStr, string name, string filename)
139 {
140 throw new Exception("The method or operation is not implemented.");
141 }
142
143 public void ForEachDefaultAsset(Action<AssetBase> action)
144 {
145 throw new Exception("The method or operation is not implemented.");
146 }
147
148 public AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage)
149 {
150 throw new Exception("The method or operation is not implemented.");
151 }
152
153 public void ForEachXmlAsset(Action<AssetBase> action)
154 {
155 throw new Exception("The method or operation is not implemented.");
156 }
157
158 #endregion
159 }
160}