aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications/Cache/GridAssetClient.cs')
-rw-r--r--OpenSim/Framework/Communications/Cache/GridAssetClient.cs85
1 files changed, 38 insertions, 47 deletions
diff --git a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
index e2924a4..47104d7 100644
--- a/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
+++ b/OpenSim/Framework/Communications/Cache/GridAssetClient.cs
@@ -36,7 +36,7 @@ using OpenSim.Framework.Servers;
36 36
37namespace OpenSim.Framework.Communications.Cache 37namespace OpenSim.Framework.Communications.Cache
38{ 38{
39 public class GridAssetClient : AssetServerBase 39 public class GridAssetClient : AssetServerBase
40 { 40 {
41 private string _assetServerUrl; 41 private string _assetServerUrl;
42 42
@@ -47,53 +47,44 @@ namespace OpenSim.Framework.Communications.Cache
47 47
48 #region IAssetServer Members 48 #region IAssetServer Members
49 49
50 protected override void RunRequests() 50 protected override void ProcessRequest(AssetRequest req)
51 { 51 {
52 while (true) 52 Stream s = null;
53 try
53 { 54 {
54 ARequest req = _assetRequests.Dequeue(); 55 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString());
55 56
56 //MainLog.Instance.Verbose("AssetStorage","Requesting asset: " + req.AssetID); 57 RestClient rc = new RestClient(_assetServerUrl);
58 rc.AddResourcePath("assets");
59 rc.AddResourcePath(req.AssetID.ToString());
60 if (req.IsTexture)
61 rc.AddQueryParameter("texture");
57 62
63 rc.RequestMethod = "GET";
64 s = rc.Request();
58 65
59 Stream s = null; 66 if (s.Length > 0)
60 try
61 { 67 {
62 MainLog.Instance.Debug("ASSETCACHE", "Querying for {0}", req.AssetID.ToString()); 68 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
63 69 AssetBase newAsset = (AssetBase)xs.Deserialize(s);
64 RestClient rc = new RestClient(_assetServerUrl); 70
65 rc.AddResourcePath("assets"); 71 _receiver.AssetReceived(newAsset, req.IsTexture);
66 rc.AddResourcePath(req.AssetID.ToString());
67 if (req.IsTexture)
68 rc.AddQueryParameter("texture");
69
70 rc.RequestMethod = "GET";
71 s = rc.Request();
72
73 if (s.Length > 0)
74 {
75 XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
76 AssetBase newAsset = (AssetBase)xs.Deserialize(s);
77
78 _receiver.AssetReceived(newAsset, req.IsTexture);
79 }
80 else
81 {
82 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString());
83 _receiver.AssetNotFound(req.AssetID);
84 }
85 } 72 }
86 catch (Exception e) 73 else
87 { 74 {
88 MainLog.Instance.Error("ASSETCACHE", e.Message); 75 MainLog.Instance.Debug("ASSETCACHE", "Asset not found {0}", req.AssetID.ToString());
89 MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString()); 76 _receiver.AssetNotFound(req.AssetID);
90 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
91 } 77 }
92 78 }
79 catch (Exception e)
80 {
81 MainLog.Instance.Error("ASSETCACHE", e.Message);
82 MainLog.Instance.Debug("ASSETCACHE", "Getting asset {0}", req.AssetID.ToString());
83 MainLog.Instance.Error("ASSETCACHE", e.StackTrace);
93 } 84 }
94 } 85 }
95 86
96 87
97 88
98 public override void UpdateAsset(AssetBase asset) 89 public override void UpdateAsset(AssetBase asset)
99 { 90 {
@@ -104,18 +95,18 @@ namespace OpenSim.Framework.Communications.Cache
104 { 95 {
105 try 96 try
106 { 97 {
107 // MemoryStream s = new MemoryStream(); 98 // MemoryStream s = new MemoryStream();
108 99
109 // XmlSerializer xs = new XmlSerializer(typeof(AssetBase)); 100 // XmlSerializer xs = new XmlSerializer(typeof(AssetBase));
110 // xs.Serialize(s, asset); 101 // xs.Serialize(s, asset);
111 // RestClient rc = new RestClient(_assetServerUrl); 102 // RestClient rc = new RestClient(_assetServerUrl);
112 MainLog.Instance.Verbose("ASSET", "Storing asset"); 103 MainLog.Instance.Verbose("ASSET", "Storing asset");
113 //rc.AddResourcePath("assets"); 104 //rc.AddResourcePath("assets");
114 // rc.RequestMethod = "POST"; 105 // rc.RequestMethod = "POST";
115 // rc.Request(s); 106 // rc.Request(s);
116 //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc); 107 //MainLog.Instance.Verbose("ASSET", "Stored {0}", rc);
117 MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/"); 108 MainLog.Instance.Verbose("ASSET", "Sending to " + _assetServerUrl + "/assets/");
118 RestObjectPoster.BeginPostObject<AssetBase>(_assetServerUrl + "/assets/", asset); 109 RestObjectPoster.BeginPostObject<AssetBase>(_assetServerUrl + "/assets/", asset);
119 } 110 }
120 catch (Exception e) 111 catch (Exception e)
121 { 112 {
@@ -132,7 +123,7 @@ namespace OpenSim.Framework.Communications.Cache
132 throw new Exception("The method or operation is not implemented."); 123 throw new Exception("The method or operation is not implemented.");
133 } 124 }
134 125
135 126
136 127
137 #endregion 128 #endregion
138 } 129 }