aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/AssetService/HGAssetService.cs
diff options
context:
space:
mode:
authordiva2009-05-17 01:38:43 +0000
committerdiva2009-05-17 01:38:43 +0000
commitaac8ca041170f6d1d648c6c5244dc3dfad428587 (patch)
tree190873d49a54f7462190331344aa308d8b6eb15f /OpenSim/Services/AssetService/HGAssetService.cs
parentSend the owner name, not the client name on SendDialog. (diff)
downloadopensim-SC-aac8ca041170f6d1d648c6c5244dc3dfad428587.zip
opensim-SC-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.gz
opensim-SC-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.bz2
opensim-SC-aac8ca041170f6d1d648c6c5244dc3dfad428587.tar.xz
HG asset transfers starting to work -- GETs only for now.
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/AssetService/HGAssetService.cs80
1 files changed, 67 insertions, 13 deletions
diff --git a/OpenSim/Services/AssetService/HGAssetService.cs b/OpenSim/Services/AssetService/HGAssetService.cs
index 87e42fe..0b6389f 100644
--- a/OpenSim/Services/AssetService/HGAssetService.cs
+++ b/OpenSim/Services/AssetService/HGAssetService.cs
@@ -28,11 +28,13 @@
28using log4net; 28using log4net;
29using Nini.Config; 29using Nini.Config;
30using System; 30using System;
31using System.Collections.Generic;
31using System.Reflection; 32using System.Reflection;
32using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Servers.Connectors;
33using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
34 36
35namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset 37namespace OpenSim.Services.AssetService
36{ 38{
37 public class HGAssetService : IAssetService 39 public class HGAssetService : IAssetService
38 { 40 {
@@ -40,6 +42,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
40 LogManager.GetLogger( 42 LogManager.GetLogger(
41 MethodBase.GetCurrentMethod().DeclaringType); 43 MethodBase.GetCurrentMethod().DeclaringType);
42 44
45 private Dictionary<string, AssetServicesConnector> m_connectors = new Dictionary<string, AssetServicesConnector>();
46
43 public HGAssetService(IConfigSource source) 47 public HGAssetService(IConfigSource source)
44 { 48 {
45 IConfig moduleConfig = source.Configs["ServiceConnectors"]; 49 IConfig moduleConfig = source.Configs["ServiceConnectors"];
@@ -50,27 +54,68 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
50 IConfig assetConfig = source.Configs["AssetService"]; 54 IConfig assetConfig = source.Configs["AssetService"];
51 if (assetConfig == null) 55 if (assetConfig == null)
52 { 56 {
53 m_log.Error("[ASSET CONNECTOR]: AssetService missing from OpanSim.ini"); 57 m_log.Error("[HG ASSET SERVICE]: AssetService missing from OpanSim.ini");
54 return; 58 return;
55 } 59 }
56 60
57 m_log.Info("[ASSET CONNECTOR]: HG asset service enabled"); 61 m_log.Info("[HG ASSET SERVICE]: HG asset service enabled");
58 } 62 }
59 } 63 }
60 64
61 // 65 private bool StringToUrlAndAssetID(string id, out string url, out string assetID)
62 // Note to Diva: 66 {
63 // 67 url = String.Empty;
64 // This is not the broker! 68 assetID = String.Empty;
65 // This module is not supposed to route anything anywhere. This is where 69
66 // the code to access remote assets (by URL) goes. It can be assumed 70 Uri assetUri;
67 // that the ID is a URL. The broker makes sure of that. 71
68 // 72 if (Uri.TryCreate(id, UriKind.Absolute, out assetUri) &&
69 // This is a disposable comment :) Feel free to remove it 73 assetUri.Scheme == Uri.UriSchemeHttp)
70 // 74 {
75 url = "http://" + assetUri.Authority;
76 assetID = assetUri.LocalPath;
77 return true;
78 }
79
80 return false;
81 }
82
83 private IAssetService GetConnector(string url)
84 {
85 AssetServicesConnector connector = null;
86 lock (m_connectors)
87 {
88 if (m_connectors.ContainsKey(url))
89 {
90 connector = m_connectors[url];
91 }
92 else
93 {
94 // We're instantiating this class explicitly, but this won't
95 // work in general, because the remote grid may be running
96 // an asset server that has a different protocol.
97 // Eventually we will want a piece of meta-protocol asking
98 // the remote server about its kind, and even asking it
99 // to send its own connector, which we would instantiate
100 // dynamically. Definitely coo, thing to do!
101 connector = new AssetServicesConnector(url);
102 m_connectors.Add(url, connector);
103 }
104 }
105 return connector;
106 }
71 107
72 public AssetBase Get(string id) 108 public AssetBase Get(string id)
73 { 109 {
110 string url = string.Empty;
111 string assetID = string.Empty;
112
113 if (StringToUrlAndAssetID(id, out url, out assetID))
114 {
115 IAssetService connector = GetConnector(url);
116 return connector.Get(assetID);
117 }
118
74 return null; 119 return null;
75 } 120 }
76 121
@@ -86,6 +131,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
86 131
87 public bool Get(string id, Object sender, AssetRetrieved handler) 132 public bool Get(string id, Object sender, AssetRetrieved handler)
88 { 133 {
134 string url = string.Empty;
135 string assetID = string.Empty;
136
137 if (StringToUrlAndAssetID(id, out url, out assetID))
138 {
139 IAssetService connector = GetConnector(url);
140 return connector.Get(assetID, sender, handler);
141 }
142
89 return false; 143 return false;
90 } 144 }
91 145