diff options
author | Adam Frisby | 2007-07-11 08:02:47 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-11 08:02:47 +0000 |
commit | 5c7ffdde0b9642a42e8f5987e06eb01220ff7776 (patch) | |
tree | 4b825dc642cb6eb9a060e54bf8d69288fbee4904 /OpenSim/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs | |
parent | Who would have known that the only way of specifying utf-8 without preamble, ... (diff) | |
download | opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.zip opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.gz opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.bz2 opensim-SC_OLD-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.xz |
* Wiping trunk in prep for Sugilite
Diffstat (limited to 'OpenSim/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs')
-rw-r--r-- | OpenSim/OpenSim.GridInterfaces/Remote/RemoteAssetServer.cs | 135 |
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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using System.Threading; | ||
32 | using System.Net; | ||
33 | using System.Net.Sockets; | ||
34 | using System.IO; | ||
35 | using libsecondlife; | ||
36 | using OpenSim.Framework.Interfaces; | ||
37 | using OpenSim.Framework.Types; | ||
38 | using OpenSim.Framework.Utilities; | ||
39 | |||
40 | namespace 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 | } | ||