diff options
author | MW | 2007-06-12 15:24:12 +0000 |
---|---|---|
committer | MW | 2007-06-12 15:24:12 +0000 |
commit | fd1a7f28abc734865b3917ff3bcbb4803395dc5a (patch) | |
tree | 044bd1f13c82ea5bf508a947d8ccb49909ce2d49 /OpenSim | |
parent | did I say I was doing some rearranging? (diff) | |
download | opensim-SC_OLD-fd1a7f28abc734865b3917ff3bcbb4803395dc5a.zip opensim-SC_OLD-fd1a7f28abc734865b3917ff3bcbb4803395dc5a.tar.gz opensim-SC_OLD-fd1a7f28abc734865b3917ff3bcbb4803395dc5a.tar.bz2 opensim-SC_OLD-fd1a7f28abc734865b3917ff3bcbb4803395dc5a.tar.xz |
Created OpenSim.Caches project and moved the assetcache to that.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/OpenSim.Caches/AssetCache.cs | 618 | ||||
-rw-r--r-- | OpenSim/OpenSim.Caches/OpenSim.Caches.csproj | 97 | ||||
-rw-r--r-- | OpenSim/OpenSim.Caches/Properties/AssemblyInfo.cs | 35 | ||||
-rw-r--r-- | OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs | 3 | ||||
-rw-r--r-- | OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj | 6 | ||||
-rw-r--r-- | OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build | 1 | ||||
-rw-r--r-- | OpenSim/OpenSim/OpenSim.csproj | 6 | ||||
-rw-r--r-- | OpenSim/OpenSim/OpenSim.exe.build | 1 |
8 files changed, 766 insertions, 1 deletions
diff --git a/OpenSim/OpenSim.Caches/AssetCache.cs b/OpenSim/OpenSim.Caches/AssetCache.cs new file mode 100644 index 0000000..fb7fd68 --- /dev/null +++ b/OpenSim/OpenSim.Caches/AssetCache.cs | |||
@@ -0,0 +1,618 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Threading; | ||
32 | using System.Reflection; | ||
33 | using libsecondlife; | ||
34 | using libsecondlife.Packets; | ||
35 | using OpenSim.Framework.Interfaces; | ||
36 | using OpenSim.Framework.Types; | ||
37 | using OpenSim.Framework.Utilities; | ||
38 | |||
39 | namespace OpenSim.Assets | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// Manages local cache of assets and their sending to viewers. | ||
43 | /// </summary> | ||
44 | public class AssetCache : IAssetReceiver | ||
45 | { | ||
46 | public Dictionary<libsecondlife.LLUUID, AssetInfo> Assets; | ||
47 | public Dictionary<libsecondlife.LLUUID, TextureImage> Textures; | ||
48 | |||
49 | public List<AssetRequest> AssetRequests = new List<AssetRequest>(); //assets ready to be sent to viewers | ||
50 | public List<AssetRequest> TextureRequests = new List<AssetRequest>(); //textures ready to be sent | ||
51 | |||
52 | public Dictionary<LLUUID, AssetRequest> RequestedAssets = new Dictionary<LLUUID, AssetRequest>(); //Assets requested from the asset server | ||
53 | public Dictionary<LLUUID, AssetRequest> RequestedTextures = new Dictionary<LLUUID, AssetRequest>(); //Textures requested from the asset server | ||
54 | |||
55 | private IAssetServer _assetServer; | ||
56 | private Thread _assetCacheThread; | ||
57 | private LLUUID[] textureList = new LLUUID[5]; | ||
58 | |||
59 | /// <summary> | ||
60 | /// | ||
61 | /// </summary> | ||
62 | public AssetCache(IAssetServer assetServer) | ||
63 | { | ||
64 | Console.WriteLine("Creating Asset cache"); | ||
65 | _assetServer = assetServer; | ||
66 | _assetServer.SetReceiver(this); | ||
67 | Assets = new Dictionary<libsecondlife.LLUUID, AssetInfo>(); | ||
68 | Textures = new Dictionary<libsecondlife.LLUUID, TextureImage>(); | ||
69 | this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); | ||
70 | this._assetCacheThread.IsBackground = true; | ||
71 | this._assetCacheThread.Start(); | ||
72 | |||
73 | } | ||
74 | |||
75 | public AssetCache(string assetServerDLLName, string assetServerURL, string assetServerKey) | ||
76 | { | ||
77 | Console.WriteLine("Creating Asset cache"); | ||
78 | _assetServer = this.LoadAssetDll(assetServerDLLName); | ||
79 | _assetServer.SetServerInfo(assetServerURL, assetServerKey); | ||
80 | _assetServer.SetReceiver(this); | ||
81 | Assets = new Dictionary<libsecondlife.LLUUID, AssetInfo>(); | ||
82 | Textures = new Dictionary<libsecondlife.LLUUID, TextureImage>(); | ||
83 | this._assetCacheThread = new Thread(new ThreadStart(RunAssetManager)); | ||
84 | this._assetCacheThread.IsBackground = true; | ||
85 | this._assetCacheThread.Start(); | ||
86 | |||
87 | } | ||
88 | |||
89 | /// <summary> | ||
90 | /// | ||
91 | /// </summary> | ||
92 | public void RunAssetManager() | ||
93 | { | ||
94 | while (true) | ||
95 | { | ||
96 | try | ||
97 | { | ||
98 | //Console.WriteLine("Asset cache loop"); | ||
99 | this.ProcessAssetQueue(); | ||
100 | this.ProcessTextureQueue(); | ||
101 | Thread.Sleep(500); | ||
102 | } | ||
103 | catch (Exception e) | ||
104 | { | ||
105 | Console.WriteLine(e.Message); | ||
106 | } | ||
107 | } | ||
108 | } | ||
109 | |||
110 | public void LoadDefaultTextureSet() | ||
111 | { | ||
112 | //hack: so we can give each user a set of textures | ||
113 | textureList[0] = new LLUUID("00000000-0000-0000-9999-000000000001"); | ||
114 | textureList[1] = new LLUUID("00000000-0000-0000-9999-000000000002"); | ||
115 | textureList[2] = new LLUUID("00000000-0000-0000-9999-000000000003"); | ||
116 | textureList[3] = new LLUUID("00000000-0000-0000-9999-000000000004"); | ||
117 | textureList[4] = new LLUUID("00000000-0000-0000-9999-000000000005"); | ||
118 | |||
119 | for (int i = 0; i < textureList.Length; i++) | ||
120 | { | ||
121 | this._assetServer.RequestAsset(textureList[i], true); | ||
122 | } | ||
123 | |||
124 | } | ||
125 | |||
126 | public AssetBase[] CreateNewInventorySet(LLUUID agentID) | ||
127 | { | ||
128 | AssetBase[] inventorySet = new AssetBase[this.textureList.Length]; | ||
129 | for (int i = 0; i < textureList.Length; i++) | ||
130 | { | ||
131 | if (this.Textures.ContainsKey(textureList[i])) | ||
132 | { | ||
133 | inventorySet[i] = this.CloneImage(agentID, this.Textures[textureList[i]]); | ||
134 | TextureImage image = new TextureImage(inventorySet[i]); | ||
135 | this.Textures.Add(image.FullID, image); | ||
136 | this._assetServer.UploadNewAsset(image); //save the asset to the asset server | ||
137 | } | ||
138 | } | ||
139 | return inventorySet; | ||
140 | } | ||
141 | |||
142 | public AssetBase GetAsset(LLUUID assetID) | ||
143 | { | ||
144 | AssetBase asset = null; | ||
145 | if (this.Textures.ContainsKey(assetID)) | ||
146 | { | ||
147 | asset = this.Textures[assetID]; | ||
148 | } | ||
149 | else if (this.Assets.ContainsKey(assetID)) | ||
150 | { | ||
151 | asset = this.Assets[assetID]; | ||
152 | } | ||
153 | return asset; | ||
154 | } | ||
155 | |||
156 | public void AddAsset(AssetBase asset) | ||
157 | { | ||
158 | if (asset.Type == 0) | ||
159 | { | ||
160 | if (!this.Textures.ContainsKey(asset.FullID)) | ||
161 | { //texture | ||
162 | TextureImage textur = new TextureImage(asset); | ||
163 | this.Textures.Add(textur.FullID, textur); | ||
164 | this._assetServer.UploadNewAsset(asset); | ||
165 | } | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | if (!this.Assets.ContainsKey(asset.FullID)) | ||
170 | { | ||
171 | AssetInfo assetInf = new AssetInfo(asset); | ||
172 | this.Assets.Add(assetInf.FullID, assetInf); | ||
173 | this._assetServer.UploadNewAsset(asset); | ||
174 | } | ||
175 | } | ||
176 | } | ||
177 | |||
178 | /// <summary> | ||
179 | /// | ||
180 | /// </summary> | ||
181 | private void ProcessTextureQueue() | ||
182 | { | ||
183 | if (this.TextureRequests.Count == 0) | ||
184 | { | ||
185 | //no requests waiting | ||
186 | return; | ||
187 | } | ||
188 | int num; | ||
189 | |||
190 | if (this.TextureRequests.Count < 5) | ||
191 | { | ||
192 | //lower than 5 so do all of them | ||
193 | num = this.TextureRequests.Count; | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | num = 5; | ||
198 | } | ||
199 | AssetRequest req; | ||
200 | for (int i = 0; i < num; i++) | ||
201 | { | ||
202 | req = (AssetRequest)this.TextureRequests[i]; | ||
203 | if (req.PacketCounter != req.NumPackets) | ||
204 | { | ||
205 | // if (req.ImageInfo.FullID == new LLUUID("00000000-0000-0000-5005-000000000005")) | ||
206 | if (req.PacketCounter == 0) | ||
207 | { | ||
208 | //first time for this request so send imagedata packet | ||
209 | if (req.NumPackets == 1) | ||
210 | { | ||
211 | //only one packet so send whole file | ||
212 | ImageDataPacket im = new ImageDataPacket(); | ||
213 | im.ImageID.Packets = 1; | ||
214 | im.ImageID.ID = req.ImageInfo.FullID; | ||
215 | im.ImageID.Size = (uint)req.ImageInfo.Data.Length; | ||
216 | im.ImageData.Data = req.ImageInfo.Data; | ||
217 | im.ImageID.Codec = 2; | ||
218 | req.RequestUser.OutPacket(im); | ||
219 | req.PacketCounter++; | ||
220 | //req.ImageInfo.l= time; | ||
221 | //System.Console.WriteLine("sent texture: "+req.image_info.FullID); | ||
222 | } | ||
223 | else | ||
224 | { | ||
225 | //more than one packet so split file up | ||
226 | ImageDataPacket im = new ImageDataPacket(); | ||
227 | im.ImageID.Packets = (ushort)req.NumPackets; | ||
228 | im.ImageID.ID = req.ImageInfo.FullID; | ||
229 | im.ImageID.Size = (uint)req.ImageInfo.Data.Length; | ||
230 | im.ImageData.Data = new byte[600]; | ||
231 | Array.Copy(req.ImageInfo.Data, 0, im.ImageData.Data, 0, 600); | ||
232 | im.ImageID.Codec = 2; | ||
233 | req.RequestUser.OutPacket(im); | ||
234 | req.PacketCounter++; | ||
235 | //req.ImageInfo.last_used = time; | ||
236 | //System.Console.WriteLine("sent first packet of texture: | ||
237 | } | ||
238 | } | ||
239 | else | ||
240 | { | ||
241 | //send imagepacket | ||
242 | //more than one packet so split file up | ||
243 | ImagePacketPacket im = new ImagePacketPacket(); | ||
244 | im.ImageID.Packet = (ushort)req.PacketCounter; | ||
245 | im.ImageID.ID = req.ImageInfo.FullID; | ||
246 | int size = req.ImageInfo.Data.Length - 600 - 1000 * (req.PacketCounter - 1); | ||
247 | if (size > 1000) size = 1000; | ||
248 | im.ImageData.Data = new byte[size]; | ||
249 | Array.Copy(req.ImageInfo.Data, 600 + 1000 * (req.PacketCounter - 1), im.ImageData.Data, 0, size); | ||
250 | req.RequestUser.OutPacket(im); | ||
251 | req.PacketCounter++; | ||
252 | //req.ImageInfo.last_used = time; | ||
253 | //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); | ||
254 | } | ||
255 | } | ||
256 | } | ||
257 | |||
258 | //remove requests that have been completed | ||
259 | int count = 0; | ||
260 | for (int i = 0; i < num; i++) | ||
261 | { | ||
262 | if (this.TextureRequests.Count > count) | ||
263 | { | ||
264 | req = (AssetRequest)this.TextureRequests[count]; | ||
265 | if (req.PacketCounter == req.NumPackets) | ||
266 | { | ||
267 | this.TextureRequests.Remove(req); | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | count++; | ||
272 | } | ||
273 | } | ||
274 | } | ||
275 | |||
276 | } | ||
277 | public void AssetReceived(AssetBase asset, bool IsTexture) | ||
278 | { | ||
279 | if (asset.FullID != LLUUID.Zero) // if it is set to zero then the asset wasn't found by the server | ||
280 | { | ||
281 | //check if it is a texture or not | ||
282 | //then add to the correct cache list | ||
283 | //then check for waiting requests for this asset/texture (in the Requested lists) | ||
284 | //and move those requests into the Requests list. | ||
285 | if (IsTexture) | ||
286 | { | ||
287 | TextureImage image = new TextureImage(asset); | ||
288 | this.Textures.Add(image.FullID, image); | ||
289 | if (this.RequestedTextures.ContainsKey(image.FullID)) | ||
290 | { | ||
291 | AssetRequest req = this.RequestedTextures[image.FullID]; | ||
292 | req.ImageInfo = image; | ||
293 | if (image.Data.LongLength > 600) | ||
294 | { | ||
295 | //over 600 bytes so split up file | ||
296 | req.NumPackets = 1 + (int)(image.Data.Length - 600 + 999) / 1000; | ||
297 | } | ||
298 | else | ||
299 | { | ||
300 | req.NumPackets = 1; | ||
301 | } | ||
302 | this.RequestedTextures.Remove(image.FullID); | ||
303 | this.TextureRequests.Add(req); | ||
304 | } | ||
305 | } | ||
306 | else | ||
307 | { | ||
308 | AssetInfo assetInf = new AssetInfo(asset); | ||
309 | this.Assets.Add(assetInf.FullID, assetInf); | ||
310 | if (this.RequestedAssets.ContainsKey(assetInf.FullID)) | ||
311 | { | ||
312 | AssetRequest req = this.RequestedAssets[assetInf.FullID]; | ||
313 | req.AssetInf = assetInf; | ||
314 | if (assetInf.Data.LongLength > 600) | ||
315 | { | ||
316 | //over 600 bytes so split up file | ||
317 | req.NumPackets = 1 + (int)(assetInf.Data.Length - 600 + 999) / 1000; | ||
318 | } | ||
319 | else | ||
320 | { | ||
321 | req.NumPackets = 1; | ||
322 | } | ||
323 | this.RequestedAssets.Remove(assetInf.FullID); | ||
324 | this.AssetRequests.Add(req); | ||
325 | } | ||
326 | } | ||
327 | } | ||
328 | } | ||
329 | |||
330 | public void AssetNotFound(AssetBase asset) | ||
331 | { | ||
332 | //the asset server had no knowledge of requested asset | ||
333 | |||
334 | } | ||
335 | |||
336 | #region Assets | ||
337 | /// <summary> | ||
338 | /// | ||
339 | /// </summary> | ||
340 | /// <param name="userInfo"></param> | ||
341 | /// <param name="transferRequest"></param> | ||
342 | public void AddAssetRequest(IClientAPI userInfo, TransferRequestPacket transferRequest) | ||
343 | { | ||
344 | LLUUID requestID = new LLUUID(transferRequest.TransferInfo.Params, 0); | ||
345 | //check to see if asset is in local cache, if not we need to request it from asset server. | ||
346 | if (!this.Assets.ContainsKey(requestID)) | ||
347 | { | ||
348 | //not found asset | ||
349 | // so request from asset server | ||
350 | if (!this.RequestedAssets.ContainsKey(requestID)) | ||
351 | { | ||
352 | AssetRequest request = new AssetRequest(); | ||
353 | request.RequestUser = userInfo; | ||
354 | request.RequestAssetID = requestID; | ||
355 | request.TransferRequestID = transferRequest.TransferInfo.TransferID; | ||
356 | this.RequestedAssets.Add(requestID, request); | ||
357 | this._assetServer.RequestAsset(requestID, false); | ||
358 | } | ||
359 | return; | ||
360 | } | ||
361 | //it is in our cache | ||
362 | AssetInfo asset = this.Assets[requestID]; | ||
363 | |||
364 | //work out how many packets it should be sent in | ||
365 | // and add to the AssetRequests list | ||
366 | AssetRequest req = new AssetRequest(); | ||
367 | req.RequestUser = userInfo; | ||
368 | req.RequestAssetID = requestID; | ||
369 | req.TransferRequestID = transferRequest.TransferInfo.TransferID; | ||
370 | req.AssetInf = asset; | ||
371 | |||
372 | if (asset.Data.LongLength > 600) | ||
373 | { | ||
374 | //over 600 bytes so split up file | ||
375 | req.NumPackets = 1 + (int)(asset.Data.Length - 600 + 999) / 1000; | ||
376 | } | ||
377 | else | ||
378 | { | ||
379 | req.NumPackets = 1; | ||
380 | } | ||
381 | |||
382 | this.AssetRequests.Add(req); | ||
383 | } | ||
384 | |||
385 | /// <summary> | ||
386 | /// | ||
387 | /// </summary> | ||
388 | private void ProcessAssetQueue() | ||
389 | { | ||
390 | if (this.AssetRequests.Count == 0) | ||
391 | { | ||
392 | //no requests waiting | ||
393 | return; | ||
394 | } | ||
395 | int num; | ||
396 | |||
397 | if (this.AssetRequests.Count < 5) | ||
398 | { | ||
399 | //lower than 5 so do all of them | ||
400 | num = this.AssetRequests.Count; | ||
401 | } | ||
402 | else | ||
403 | { | ||
404 | num = 5; | ||
405 | } | ||
406 | AssetRequest req; | ||
407 | for (int i = 0; i < num; i++) | ||
408 | { | ||
409 | req = (AssetRequest)this.AssetRequests[i]; | ||
410 | |||
411 | TransferInfoPacket Transfer = new TransferInfoPacket(); | ||
412 | Transfer.TransferInfo.ChannelType = 2; | ||
413 | Transfer.TransferInfo.Status = 0; | ||
414 | Transfer.TransferInfo.TargetType = 0; | ||
415 | Transfer.TransferInfo.Params = req.RequestAssetID.GetBytes(); | ||
416 | Transfer.TransferInfo.Size = (int)req.AssetInf.Data.Length; | ||
417 | Transfer.TransferInfo.TransferID = req.TransferRequestID; | ||
418 | req.RequestUser.OutPacket(Transfer); | ||
419 | |||
420 | if (req.NumPackets == 1) | ||
421 | { | ||
422 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
423 | TransferPacket.TransferData.Packet = 0; | ||
424 | TransferPacket.TransferData.ChannelType = 2; | ||
425 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
426 | TransferPacket.TransferData.Data = req.AssetInf.Data; | ||
427 | TransferPacket.TransferData.Status = 1; | ||
428 | req.RequestUser.OutPacket(TransferPacket); | ||
429 | } | ||
430 | else | ||
431 | { | ||
432 | //more than one packet so split file up , for now it can't be bigger than 2000 bytes | ||
433 | TransferPacketPacket TransferPacket = new TransferPacketPacket(); | ||
434 | TransferPacket.TransferData.Packet = 0; | ||
435 | TransferPacket.TransferData.ChannelType = 2; | ||
436 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
437 | byte[] chunk = new byte[1000]; | ||
438 | Array.Copy(req.AssetInf.Data, chunk, 1000); | ||
439 | TransferPacket.TransferData.Data = chunk; | ||
440 | TransferPacket.TransferData.Status = 0; | ||
441 | req.RequestUser.OutPacket(TransferPacket); | ||
442 | |||
443 | TransferPacket = new TransferPacketPacket(); | ||
444 | TransferPacket.TransferData.Packet = 1; | ||
445 | TransferPacket.TransferData.ChannelType = 2; | ||
446 | TransferPacket.TransferData.TransferID = req.TransferRequestID; | ||
447 | byte[] chunk1 = new byte[(req.AssetInf.Data.Length - 1000)]; | ||
448 | Array.Copy(req.AssetInf.Data, 1000, chunk1, 0, chunk1.Length); | ||
449 | TransferPacket.TransferData.Data = chunk1; | ||
450 | TransferPacket.TransferData.Status = 1; | ||
451 | req.RequestUser.OutPacket(TransferPacket); | ||
452 | } | ||
453 | |||
454 | } | ||
455 | |||
456 | //remove requests that have been completed | ||
457 | for (int i = 0; i < num; i++) | ||
458 | { | ||
459 | this.AssetRequests.RemoveAt(0); | ||
460 | } | ||
461 | |||
462 | } | ||
463 | |||
464 | public AssetInfo CloneAsset(LLUUID newOwner, AssetInfo sourceAsset) | ||
465 | { | ||
466 | AssetInfo newAsset = new AssetInfo(); | ||
467 | newAsset.Data = new byte[sourceAsset.Data.Length]; | ||
468 | Array.Copy(sourceAsset.Data, newAsset.Data, sourceAsset.Data.Length); | ||
469 | newAsset.FullID = LLUUID.Random(); | ||
470 | newAsset.Type = sourceAsset.Type; | ||
471 | newAsset.InvType = sourceAsset.InvType; | ||
472 | return (newAsset); | ||
473 | } | ||
474 | #endregion | ||
475 | |||
476 | #region Textures | ||
477 | /// <summary> | ||
478 | /// | ||
479 | /// </summary> | ||
480 | /// <param name="userInfo"></param> | ||
481 | /// <param name="imageID"></param> | ||
482 | public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID) | ||
483 | { | ||
484 | //check to see if texture is in local cache, if not request from asset server | ||
485 | if (!this.Textures.ContainsKey(imageID)) | ||
486 | { | ||
487 | if (!this.RequestedTextures.ContainsKey(imageID)) | ||
488 | { | ||
489 | //not is cache so request from asset server | ||
490 | AssetRequest request = new AssetRequest(); | ||
491 | request.RequestUser = userInfo; | ||
492 | request.RequestAssetID = imageID; | ||
493 | request.IsTextureRequest = true; | ||
494 | this.RequestedTextures.Add(imageID, request); | ||
495 | this._assetServer.RequestAsset(imageID, true); | ||
496 | } | ||
497 | return; | ||
498 | } | ||
499 | |||
500 | TextureImage imag = this.Textures[imageID]; | ||
501 | AssetRequest req = new AssetRequest(); | ||
502 | req.RequestUser = userInfo; | ||
503 | req.RequestAssetID = imageID; | ||
504 | req.IsTextureRequest = true; | ||
505 | req.ImageInfo = imag; | ||
506 | |||
507 | if (imag.Data.LongLength > 600) | ||
508 | { | ||
509 | //over 600 bytes so split up file | ||
510 | req.NumPackets = 1 + (int)(imag.Data.Length - 600 + 999) / 1000; | ||
511 | } | ||
512 | else | ||
513 | { | ||
514 | req.NumPackets = 1; | ||
515 | } | ||
516 | this.TextureRequests.Add(req); | ||
517 | } | ||
518 | |||
519 | public TextureImage CloneImage(LLUUID newOwner, TextureImage source) | ||
520 | { | ||
521 | TextureImage newImage = new TextureImage(); | ||
522 | newImage.Data = new byte[source.Data.Length]; | ||
523 | Array.Copy(source.Data, newImage.Data, source.Data.Length); | ||
524 | //newImage.filename = source.filename; | ||
525 | newImage.FullID = LLUUID.Random(); | ||
526 | newImage.Name = source.Name; | ||
527 | return (newImage); | ||
528 | } | ||
529 | #endregion | ||
530 | |||
531 | private IAssetServer LoadAssetDll(string dllName) | ||
532 | { | ||
533 | Assembly pluginAssembly = Assembly.LoadFrom(dllName); | ||
534 | IAssetServer server = null; | ||
535 | |||
536 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
537 | { | ||
538 | if (pluginType.IsPublic) | ||
539 | { | ||
540 | if (!pluginType.IsAbstract) | ||
541 | { | ||
542 | Type typeInterface = pluginType.GetInterface("IAssetPlugin", true); | ||
543 | |||
544 | if (typeInterface != null) | ||
545 | { | ||
546 | IAssetPlugin plug = (IAssetPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
547 | server = plug.GetAssetServer(); | ||
548 | break; | ||
549 | } | ||
550 | |||
551 | typeInterface = null; | ||
552 | } | ||
553 | } | ||
554 | } | ||
555 | pluginAssembly = null; | ||
556 | return server; | ||
557 | } | ||
558 | |||
559 | } | ||
560 | |||
561 | public class AssetRequest | ||
562 | { | ||
563 | public IClientAPI RequestUser; | ||
564 | public LLUUID RequestAssetID; | ||
565 | public AssetInfo AssetInf; | ||
566 | public TextureImage ImageInfo; | ||
567 | public LLUUID TransferRequestID; | ||
568 | public long DataPointer = 0; | ||
569 | public int NumPackets = 0; | ||
570 | public int PacketCounter = 0; | ||
571 | public bool IsTextureRequest; | ||
572 | //public bool AssetInCache; | ||
573 | //public int TimeRequested; | ||
574 | |||
575 | public AssetRequest() | ||
576 | { | ||
577 | |||
578 | } | ||
579 | } | ||
580 | |||
581 | public class AssetInfo : AssetBase | ||
582 | { | ||
583 | public AssetInfo() | ||
584 | { | ||
585 | |||
586 | } | ||
587 | |||
588 | public AssetInfo(AssetBase aBase) | ||
589 | { | ||
590 | Data = aBase.Data; | ||
591 | FullID = aBase.FullID; | ||
592 | Type = aBase.Type; | ||
593 | InvType = aBase.InvType; | ||
594 | Name = aBase.Name; | ||
595 | Description = aBase.Description; | ||
596 | } | ||
597 | } | ||
598 | |||
599 | public class TextureImage : AssetBase | ||
600 | { | ||
601 | public TextureImage() | ||
602 | { | ||
603 | |||
604 | } | ||
605 | |||
606 | public TextureImage(AssetBase aBase) | ||
607 | { | ||
608 | Data = aBase.Data; | ||
609 | FullID = aBase.FullID; | ||
610 | Type = aBase.Type; | ||
611 | InvType = aBase.InvType; | ||
612 | Name = aBase.Name; | ||
613 | Description = aBase.Description; | ||
614 | } | ||
615 | } | ||
616 | |||
617 | } | ||
618 | |||
diff --git a/OpenSim/OpenSim.Caches/OpenSim.Caches.csproj b/OpenSim/OpenSim.Caches/OpenSim.Caches.csproj new file mode 100644 index 0000000..c59078e --- /dev/null +++ b/OpenSim/OpenSim.Caches/OpenSim.Caches.csproj | |||
@@ -0,0 +1,97 @@ | |||
1 | <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
2 | <PropertyGroup> | ||
3 | <ProjectType>Local</ProjectType> | ||
4 | <ProductVersion>8.0.50727</ProductVersion> | ||
5 | <SchemaVersion>2.0</SchemaVersion> | ||
6 | <ProjectGuid>{1938EB12-0000-0000-0000-000000000000}</ProjectGuid> | ||
7 | <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
8 | <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
9 | <ApplicationIcon></ApplicationIcon> | ||
10 | <AssemblyKeyContainerName> | ||
11 | </AssemblyKeyContainerName> | ||
12 | <AssemblyName>OpenSim.Caches</AssemblyName> | ||
13 | <DefaultClientScript>JScript</DefaultClientScript> | ||
14 | <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> | ||
15 | <DefaultTargetSchema>IE50</DefaultTargetSchema> | ||
16 | <DelaySign>false</DelaySign> | ||
17 | <OutputType>Library</OutputType> | ||
18 | <AppDesignerFolder></AppDesignerFolder> | ||
19 | <RootNamespace>OpenSim.Caches</RootNamespace> | ||
20 | <StartupObject></StartupObject> | ||
21 | <FileUpgradeFlags> | ||
22 | </FileUpgradeFlags> | ||
23 | </PropertyGroup> | ||
24 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
25 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
26 | <BaseAddress>285212672</BaseAddress> | ||
27 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
28 | <ConfigurationOverrideFile> | ||
29 | </ConfigurationOverrideFile> | ||
30 | <DefineConstants>TRACE;DEBUG</DefineConstants> | ||
31 | <DocumentationFile></DocumentationFile> | ||
32 | <DebugSymbols>True</DebugSymbols> | ||
33 | <FileAlignment>4096</FileAlignment> | ||
34 | <Optimize>False</Optimize> | ||
35 | <OutputPath>..\..\bin\</OutputPath> | ||
36 | <RegisterForComInterop>False</RegisterForComInterop> | ||
37 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
38 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
39 | <WarningLevel>4</WarningLevel> | ||
40 | <NoWarn></NoWarn> | ||
41 | </PropertyGroup> | ||
42 | <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
43 | <AllowUnsafeBlocks>False</AllowUnsafeBlocks> | ||
44 | <BaseAddress>285212672</BaseAddress> | ||
45 | <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow> | ||
46 | <ConfigurationOverrideFile> | ||
47 | </ConfigurationOverrideFile> | ||
48 | <DefineConstants>TRACE</DefineConstants> | ||
49 | <DocumentationFile></DocumentationFile> | ||
50 | <DebugSymbols>False</DebugSymbols> | ||
51 | <FileAlignment>4096</FileAlignment> | ||
52 | <Optimize>True</Optimize> | ||
53 | <OutputPath>..\..\bin\</OutputPath> | ||
54 | <RegisterForComInterop>False</RegisterForComInterop> | ||
55 | <RemoveIntegerChecks>False</RemoveIntegerChecks> | ||
56 | <TreatWarningsAsErrors>False</TreatWarningsAsErrors> | ||
57 | <WarningLevel>4</WarningLevel> | ||
58 | <NoWarn></NoWarn> | ||
59 | </PropertyGroup> | ||
60 | <ItemGroup> | ||
61 | <Reference Include="System" > | ||
62 | <HintPath>System.dll</HintPath> | ||
63 | <Private>False</Private> | ||
64 | </Reference> | ||
65 | <Reference Include="System.Xml" > | ||
66 | <HintPath>System.Xml.dll</HintPath> | ||
67 | <Private>False</Private> | ||
68 | </Reference> | ||
69 | <Reference Include="libsecondlife.dll" > | ||
70 | <HintPath>..\..\bin\libsecondlife.dll</HintPath> | ||
71 | <Private>False</Private> | ||
72 | </Reference> | ||
73 | </ItemGroup> | ||
74 | <ItemGroup> | ||
75 | <ProjectReference Include="..\..\Common\OpenSim.Framework\OpenSim.Framework.csproj"> | ||
76 | <Name>OpenSim.Framework</Name> | ||
77 | <Project>{8ACA2445-0000-0000-0000-000000000000}</Project> | ||
78 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
79 | <Private>False</Private> | ||
80 | </ProjectReference> | ||
81 | </ItemGroup> | ||
82 | <ItemGroup> | ||
83 | <Compile Include="AssetCache.cs"> | ||
84 | <SubType>Code</SubType> | ||
85 | </Compile> | ||
86 | <Compile Include="Properties\AssemblyInfo.cs"> | ||
87 | <SubType>Code</SubType> | ||
88 | </Compile> | ||
89 | </ItemGroup> | ||
90 | <Import Project="$(MSBuildBinPath)\Microsoft.CSHARP.Targets" /> | ||
91 | <PropertyGroup> | ||
92 | <PreBuildEvent> | ||
93 | </PreBuildEvent> | ||
94 | <PostBuildEvent> | ||
95 | </PostBuildEvent> | ||
96 | </PropertyGroup> | ||
97 | </Project> | ||
diff --git a/OpenSim/OpenSim.Caches/Properties/AssemblyInfo.cs b/OpenSim/OpenSim.Caches/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..00f5dfe --- /dev/null +++ b/OpenSim/OpenSim.Caches/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,35 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Caches")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("")] | ||
12 | [assembly: AssemblyProduct("OpenSim.Caches")] | ||
13 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("2b15ddbf-0341-49a6-85c0-cece268a4518")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | // You can specify all the values or you can default the Revision and Build Numbers | ||
33 | // by using the '*' as shown below: | ||
34 | [assembly: AssemblyVersion("1.0.0.0")] | ||
35 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs b/OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs index 04f411c..3d17346 100644 --- a/OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs +++ b/OpenSim/OpenSim.RegionServer/Assets/AssetCache.cs | |||
@@ -39,6 +39,7 @@ using OpenSim.Framework.Utilities; | |||
39 | 39 | ||
40 | namespace OpenSim.Assets | 40 | namespace OpenSim.Assets |
41 | { | 41 | { |
42 | /* | ||
42 | /// <summary> | 43 | /// <summary> |
43 | /// Manages local cache of assets and their sending to viewers. | 44 | /// Manages local cache of assets and their sending to viewers. |
44 | /// </summary> | 45 | /// </summary> |
@@ -614,5 +615,5 @@ namespace OpenSim.Assets | |||
614 | Description = aBase.Description; | 615 | Description = aBase.Description; |
615 | } | 616 | } |
616 | } | 617 | } |
617 | 618 | */ | |
618 | } | 619 | } |
diff --git a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj index 738dbf8..3da0336 100644 --- a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj +++ b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.csproj | |||
@@ -116,6 +116,12 @@ | |||
116 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 116 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
117 | <Private>False</Private> | 117 | <Private>False</Private> |
118 | </ProjectReference> | 118 | </ProjectReference> |
119 | <ProjectReference Include="..\OpenSim.Caches\OpenSim.Caches.csproj"> | ||
120 | <Name>OpenSim.Caches</Name> | ||
121 | <Project>{1938EB12-0000-0000-0000-000000000000}</Project> | ||
122 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
123 | <Private>False</Private> | ||
124 | </ProjectReference> | ||
119 | <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj"> | 125 | <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj"> |
120 | <Name>XMLRPC</Name> | 126 | <Name>XMLRPC</Name> |
121 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> | 127 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> |
diff --git a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build index 8efdf22..a02e3d9 100644 --- a/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build +++ b/OpenSim/OpenSim.RegionServer/OpenSim.RegionServer.dll.build | |||
@@ -44,6 +44,7 @@ | |||
44 | <include name="../../bin/OpenSim.GenericConfig.Xml.dll" /> | 44 | <include name="../../bin/OpenSim.GenericConfig.Xml.dll" /> |
45 | <include name="../../bin/OpenSim.Physics.Manager.dll" /> | 45 | <include name="../../bin/OpenSim.Physics.Manager.dll" /> |
46 | <include name="../../bin/OpenSim.Servers.dll" /> | 46 | <include name="../../bin/OpenSim.Servers.dll" /> |
47 | <include name="../../bin/OpenSim.Caches.dll" /> | ||
47 | <include name="../../bin/XMLRPC.dll" /> | 48 | <include name="../../bin/XMLRPC.dll" /> |
48 | </references> | 49 | </references> |
49 | </csc> | 50 | </csc> |
diff --git a/OpenSim/OpenSim/OpenSim.csproj b/OpenSim/OpenSim/OpenSim.csproj index 2308c99..60fd55b 100644 --- a/OpenSim/OpenSim/OpenSim.csproj +++ b/OpenSim/OpenSim/OpenSim.csproj | |||
@@ -134,6 +134,12 @@ | |||
134 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | 134 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> |
135 | <Private>False</Private> | 135 | <Private>False</Private> |
136 | </ProjectReference> | 136 | </ProjectReference> |
137 | <ProjectReference Include="..\OpenSim.Caches\OpenSim.Caches.csproj"> | ||
138 | <Name>OpenSim.Caches</Name> | ||
139 | <Project>{1938EB12-0000-0000-0000-000000000000}</Project> | ||
140 | <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> | ||
141 | <Private>False</Private> | ||
142 | </ProjectReference> | ||
137 | <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj"> | 143 | <ProjectReference Include="..\..\Common\XmlRpcCS\XMLRPC.csproj"> |
138 | <Name>XMLRPC</Name> | 144 | <Name>XMLRPC</Name> |
139 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> | 145 | <Project>{8E81D43C-0000-0000-0000-000000000000}</Project> |
diff --git a/OpenSim/OpenSim/OpenSim.exe.build b/OpenSim/OpenSim/OpenSim.exe.build index 6038583..6f67b2d 100644 --- a/OpenSim/OpenSim/OpenSim.exe.build +++ b/OpenSim/OpenSim/OpenSim.exe.build | |||
@@ -33,6 +33,7 @@ | |||
33 | <include name="../../bin/OpenSim.RegionServer.dll" /> | 33 | <include name="../../bin/OpenSim.RegionServer.dll" /> |
34 | <include name="../../bin/OpenSim.GenericConfig.Xml.dll" /> | 34 | <include name="../../bin/OpenSim.GenericConfig.Xml.dll" /> |
35 | <include name="../../bin/OpenGrid.Framework.Communications.dll" /> | 35 | <include name="../../bin/OpenGrid.Framework.Communications.dll" /> |
36 | <include name="../../bin/OpenSim.Caches.dll" /> | ||
36 | <include name="../../bin/XMLRPC.dll" /> | 37 | <include name="../../bin/XMLRPC.dll" /> |
37 | </references> | 38 | </references> |
38 | </csc> | 39 | </csc> |