34 using System.Xml.Serialization;
35 using System.Collections;
36 using System.Collections.Generic;
37 using System.Reflection;
39 using OpenSim.Framework;
40 using OpenSim.Framework.ServiceAuth;
41 using OpenSim.Region.Framework.Interfaces;
42 using OpenSim.Region.Framework.Scenes;
43 using OpenSim.Services.Interfaces;
48 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"XBakes.Module")]
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private UTF8Encoding enc =
new UTF8Encoding();
54 private string m_URL = String.Empty;
55 private static XmlSerializer m_serializer =
new XmlSerializer(typeof(
AssetBase));
61 IConfig config = configSource.Configs[
"XBakes"];
65 m_URL = config.GetString(
"URL", String.Empty);
66 m_Auth = ServiceAuth.Create(configSource,
"XBakes");
91 get {
return "XBakes.Module"; }
94 public Type ReplaceableInterface
101 if (m_URL ==
String.Empty)
106 List<WearableCacheItem> ret =
new List<WearableCacheItem>();
107 rc.AddResourcePath(
"bakes");
108 rc.AddResourcePath(id.ToString());
110 rc.RequestMethod =
"GET";
114 using(Stream s = rc.Request(m_Auth))
116 using(XmlTextReader sr =
new XmlTextReader(s))
118 sr.ReadStartElement(
"BakedAppearance");
119 while(sr.LocalName ==
"BakedTexture")
121 string sTextureIndex = sr.GetAttribute(
"TextureIndex");
122 int lTextureIndex = Convert.ToInt32(sTextureIndex);
123 string sCacheId = sr.GetAttribute(
"CacheId");
124 UUID lCacheId = UUID.Zero;
125 if(!(
UUID.TryParse(sCacheId,out lCacheId)))
130 sr.ReadStartElement(
"BakedTexture");
131 if(sr.Name==
"AssetBase")
134 ret.Add(
new WearableCacheItem() { CacheId = lCacheId,TextureIndex = (uint)lTextureIndex,TextureAsset = a,TextureID = a.
FullID });
138 m_log.DebugFormat(
"[XBakes]: read {0} textures for user {1}",ret.Count,id);
140 return ret.ToArray();
160 if (m_URL ==
String.Empty)
164 MemoryStream reqStream;
166 using (MemoryStream bakeStream =
new MemoryStream())
167 using (XmlTextWriter bakeWriter =
new XmlTextWriter(bakeStream, null))
169 bakeWriter.WriteStartElement(String.Empty,
"BakedAppearance", String.Empty);
171 for (
int i = 0; i < data.Length; i++)
173 if (data[i] != null && data[i].TextureAsset != null)
175 bakeWriter.WriteStartElement(String.Empty,
"BakedTexture", String.Empty);
176 bakeWriter.WriteAttributeString(String.Empty,
"TextureIndex", String.Empty, data[i].TextureIndex.ToString());
177 bakeWriter.WriteAttributeString(String.Empty,
"CacheId", String.Empty, data[i].CacheId.ToString());
179 m_serializer.Serialize(bakeWriter, data[i].TextureAsset);
181 bakeWriter.WriteEndElement();
186 bakeWriter.WriteEndElement();
189 reqStream =
new MemoryStream(bakeStream.ToArray());
197 rc.AddResourcePath(
"bakes");
198 rc.AddResourcePath(agentId.ToString());
199 rc.RequestMethod =
"POST";
201 rc.Request(reqStream, m_Auth);
202 m_log.DebugFormat(
"[XBakes]: stored {0} textures for user {1}", numberWears, agentId);
204 }, null,
"XBakesModule.Store"
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void UpdateMeshAvatar(UUID agentId)
Asset class. All Assets are reference by this class or a class derived from this class ...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
Interactive OpenSim region server
void Store(UUID agentId, WearableCacheItem[] data)
void Initialise(IConfigSource configSource)
This is called to initialize the region module. For shared modules, this is called exactly once...
Implementation of a generic REST client
WearableCacheItem[] Get(UUID id)
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...