From 65c0996a9cfe1a4dbddad5493d58ddda1ef8a9a6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 10 May 2009 16:51:14 +0000 Subject: Use the new async handling class to actually make the new asset service's async request perform asynchronously --- .../Asset/RemoteAssetServiceConnector.cs | 46 ++++++++++++++++------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs index 667840f..c409d15 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Asset/RemoteAssetServiceConnector.cs @@ -141,8 +141,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset if (asset == null) { - asset = SynchronousRestObjectPoster. - BeginPostObject("GET", uri, 0); + asset = SynchronousRestObjectRequester. + MakeRequest("GET", uri, 0); if (m_Cache != null) m_Cache.Cache(asset); @@ -162,8 +162,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset string uri = m_ServerURI + "/assets/" + id + "/metadata"; - AssetMetadata asset = SynchronousRestObjectPoster. - BeginPostObject("GET", uri, 0); + AssetMetadata asset = SynchronousRestObjectRequester. + MakeRequest("GET", uri, 0); return asset; } @@ -202,16 +202,38 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset public bool Get(string id, Object sender, AssetRetrieved handler) { - AssetBase asset = Get(id); - handler(id, sender, asset); + string uri = m_ServerURI + "/assets/" + id; + + AssetBase asset = null; + if (m_Cache != null) + asset = m_Cache.Get(id); + + if (asset == null) + { + AsynchronousRestObjectRequester. + MakeRequest("GET", uri, 0, + delegate(AssetBase a) + { + if (m_Cache != null) + m_Cache.Cache(a); + handler(id, sender, a); + }); + + } + else + { + handler(id, sender, asset); + } + return true; } + public string Store(AssetBase asset) { string uri = m_ServerURI + "/assets/"; - string newID = SynchronousRestObjectPoster. - BeginPostObject("POST", uri, asset); + string newID = SynchronousRestObjectRequester. + MakeRequest("POST", uri, asset); if (newID != String.Empty) { @@ -241,8 +263,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset string uri = m_ServerURI + "/assets/" + id; - if (SynchronousRestObjectPoster. - BeginPostObject("POST", uri, asset)) + if (SynchronousRestObjectRequester. + MakeRequest("POST", uri, asset)) { if (m_Cache != null) m_Cache.Cache(asset); @@ -256,8 +278,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset { string uri = m_ServerURI + "/assets/" + id; - if (SynchronousRestObjectPoster. - BeginPostObject("DELETE", uri, 0)) + if (SynchronousRestObjectRequester. + MakeRequest("DELETE", uri, 0)) { if (m_Cache != null) m_Cache.Expire(id); -- cgit v1.1