aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs')
-rw-r--r--OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs133
1 files changed, 0 insertions, 133 deletions
diff --git a/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
deleted file mode 100644
index f81bb8d..0000000
--- a/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs
+++ /dev/null
@@ -1,133 +0,0 @@
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*/
28using System.IO;
29using System.Net;
30using System.Text;
31using System.Threading;
32using libsecondlife;
33using OpenSim.Framework.Console;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework.Types;
36using OpenSim.Framework.Utilities;
37
38namespace OpenSim.Region.GridInterfaces.Remote
39{
40 public class RemoteAssetServer : IAssetServer
41 {
42 private IAssetReceiver _receiver;
43 private BlockingQueue<ARequest> _assetRequests;
44 private Thread _remoteAssetServerThread;
45 private string AssetServerUrl;
46 private string AssetSendKey;
47
48 public RemoteAssetServer()
49 {
50 this._assetRequests = new BlockingQueue<ARequest>();
51 this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests));
52 this._remoteAssetServerThread.IsBackground = true;
53 this._remoteAssetServerThread.Start();
54 MainLog.Instance.Verbose("Remote Asset Server class created");
55 }
56
57 public void SetReceiver(IAssetReceiver receiver)
58 {
59 this._receiver = receiver;
60 }
61
62 public void RequestAsset(LLUUID assetID, bool isTexture)
63 {
64 ARequest req = new ARequest();
65 req.AssetID = assetID;
66 req.IsTexture = isTexture;
67 this._assetRequests.Enqueue(req);
68 }
69
70 public void UpdateAsset(AssetBase asset)
71 {
72
73 }
74
75 public void UploadNewAsset(AssetBase asset)
76 {
77 Encoding Windows1252Encoding = Encoding.GetEncoding(1252);
78 string ret = Windows1252Encoding.GetString(asset.Data);
79 byte[] buffer = Windows1252Encoding.GetBytes(ret);
80 WebClient client = new WebClient();
81 client.UploadData(this.AssetServerUrl + "assets/" + asset.FullID, buffer);
82
83 }
84
85 public void SetServerInfo(string ServerUrl, string ServerKey)
86 {
87 this.AssetServerUrl = ServerUrl;
88 this.AssetSendKey = ServerKey;
89 }
90
91 private void RunRequests()
92 {
93 while (true)
94 {
95 //we need to add support for the asset server not knowing about a requested asset
96 // 404... THE MAGIC FILE NOT FOUND ERROR, very useful for telling you things such as a file (or asset ;) ) not being found!!!!!!!!!!! it's 2:22AM
97 ARequest req = this._assetRequests.Dequeue();
98 LLUUID assetID = req.AssetID;
99 // OpenSim.Framework.Console.MainLog.Instance.Verbose(" RemoteAssetServer- Got a AssetServer request, processing it - " + this.AssetServerUrl + "assets/" + assetID);
100 WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "assets/" + assetID);
101 WebResponse AssetResponse = AssetLoad.GetResponse();
102 byte[] idata = new byte[(int)AssetResponse.ContentLength];
103 BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
104 idata = br.ReadBytes((int)AssetResponse.ContentLength);
105 br.Close();
106
107 AssetBase asset = new AssetBase();
108 asset.FullID = assetID;
109 asset.Data = idata;
110 _receiver.AssetReceived(asset, req.IsTexture);
111 }
112 }
113
114 public void Close()
115 {
116
117 }
118 }
119
120 public class RemoteAssetPlugin : IAssetPlugin
121 {
122 public RemoteAssetPlugin()
123 {
124
125 }
126
127 public IAssetServer GetAssetServer()
128 {
129 return (new RemoteAssetServer());
130 }
131 }
132
133}