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