From 45567b71b8c3c6f2e52dacdda92671048bb3faf0 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Wed, 19 Dec 2007 18:05:45 +0000 Subject: Refactor asset request processing for consistent status information on whether an asset was actually found or not --- .../Communications/Cache/AssetServerBase.cs | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'OpenSim/Framework/Communications/Cache/AssetServerBase.cs') diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 659b9c9..4d03fee 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs @@ -48,7 +48,38 @@ namespace OpenSim.Framework.Communications.Cache protected abstract void StoreAsset(AssetBase asset); protected abstract void CommitAssets(); - protected abstract void ProcessRequest(AssetRequest req); + /// + /// This method must be implemented by a subclass to retrieve the asset named in the + /// AssetRequest. If the asset is not found, null should be returned. + /// + /// + /// + protected abstract AssetBase _ProcessRequest(AssetRequest req); + + /// + /// Process an asset request. This method will call _ProcessRequest(AssetRequest req) + /// on the subclass. + /// + /// + protected void ProcessRequest(AssetRequest req) + { + AssetBase asset = _ProcessRequest(req); + + if (asset != null) + { + MainLog.Instance.Verbose( + "ASSET", "Asset {0} received from asset server", req.AssetID); + + _receiver.AssetReceived(asset, req.IsTexture); + } + else + { + MainLog.Instance.Error( + "ASSET", "Asset {0} not found by asset server", req.AssetID); + + _receiver.AssetNotFound(req.AssetID); + } + } public void LoadDefaultAssets() { @@ -117,9 +148,9 @@ namespace OpenSim.Framework.Communications.Cache AssetRequest req = new AssetRequest(); req.AssetID = assetID; req.IsTexture = isTexture; - MainLog.Instance.Verbose("ASSET","Adding {0} to request queue", assetID); _assetRequests.Enqueue(req); - MainLog.Instance.Verbose("ASSET","Added {0} to request queue", assetID); + + MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID); } public virtual void UpdateAsset(AssetBase asset) -- cgit v1.1