diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs | 266 |
1 files changed, 133 insertions, 133 deletions
diff --git a/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs index 8643736..f81bb8d 100644 --- a/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs +++ b/OpenSim/Region/GridInterfaces/Remote/RemoteAssetServer.cs | |||
@@ -1,133 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System.IO; | 28 | using System.IO; |
29 | using System.Net; | 29 | using System.Net; |
30 | using System.Text; | 30 | using System.Text; |
31 | using System.Threading; | 31 | using System.Threading; |
32 | using libsecondlife; | 32 | using libsecondlife; |
33 | using OpenSim.Framework.Console; | 33 | using OpenSim.Framework.Console; |
34 | using OpenSim.Framework.Interfaces; | 34 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Framework.Types; | 35 | using OpenSim.Framework.Types; |
36 | using OpenSim.Framework.Utilities; | 36 | using OpenSim.Framework.Utilities; |
37 | 37 | ||
38 | namespace OpenSim.Region.GridInterfaces.Remote | 38 | namespace OpenSim.Region.GridInterfaces.Remote |
39 | { | 39 | { |
40 | public class RemoteAssetServer : IAssetServer | 40 | public class RemoteAssetServer : IAssetServer |
41 | { | 41 | { |
42 | private IAssetReceiver _receiver; | 42 | private IAssetReceiver _receiver; |
43 | private BlockingQueue<ARequest> _assetRequests; | 43 | private BlockingQueue<ARequest> _assetRequests; |
44 | private Thread _remoteAssetServerThread; | 44 | private Thread _remoteAssetServerThread; |
45 | private string AssetServerUrl; | 45 | private string AssetServerUrl; |
46 | private string AssetSendKey; | 46 | private string AssetSendKey; |
47 | 47 | ||
48 | public RemoteAssetServer() | 48 | public RemoteAssetServer() |
49 | { | 49 | { |
50 | this._assetRequests = new BlockingQueue<ARequest>(); | 50 | this._assetRequests = new BlockingQueue<ARequest>(); |
51 | this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests)); | 51 | this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests)); |
52 | this._remoteAssetServerThread.IsBackground = true; | 52 | this._remoteAssetServerThread.IsBackground = true; |
53 | this._remoteAssetServerThread.Start(); | 53 | this._remoteAssetServerThread.Start(); |
54 | MainLog.Instance.Verbose("Remote Asset Server class created"); | 54 | MainLog.Instance.Verbose("Remote Asset Server class created"); |
55 | } | 55 | } |
56 | 56 | ||
57 | public void SetReceiver(IAssetReceiver receiver) | 57 | public void SetReceiver(IAssetReceiver receiver) |
58 | { | 58 | { |
59 | this._receiver = receiver; | 59 | this._receiver = receiver; |
60 | } | 60 | } |
61 | 61 | ||
62 | public void RequestAsset(LLUUID assetID, bool isTexture) | 62 | public void RequestAsset(LLUUID assetID, bool isTexture) |
63 | { | 63 | { |
64 | ARequest req = new ARequest(); | 64 | ARequest req = new ARequest(); |
65 | req.AssetID = assetID; | 65 | req.AssetID = assetID; |
66 | req.IsTexture = isTexture; | 66 | req.IsTexture = isTexture; |
67 | this._assetRequests.Enqueue(req); | 67 | this._assetRequests.Enqueue(req); |
68 | } | 68 | } |
69 | 69 | ||
70 | public void UpdateAsset(AssetBase asset) | 70 | public void UpdateAsset(AssetBase asset) |
71 | { | 71 | { |
72 | 72 | ||
73 | } | 73 | } |
74 | 74 | ||
75 | public void UploadNewAsset(AssetBase asset) | 75 | public void UploadNewAsset(AssetBase asset) |
76 | { | 76 | { |
77 | Encoding Windows1252Encoding = Encoding.GetEncoding(1252); | 77 | Encoding Windows1252Encoding = Encoding.GetEncoding(1252); |
78 | string ret = Windows1252Encoding.GetString(asset.Data); | 78 | string ret = Windows1252Encoding.GetString(asset.Data); |
79 | byte[] buffer = Windows1252Encoding.GetBytes(ret); | 79 | byte[] buffer = Windows1252Encoding.GetBytes(ret); |
80 | WebClient client = new WebClient(); | 80 | WebClient client = new WebClient(); |
81 | client.UploadData(this.AssetServerUrl + "assets/" + asset.FullID, buffer); | 81 | client.UploadData(this.AssetServerUrl + "assets/" + asset.FullID, buffer); |
82 | 82 | ||
83 | } | 83 | } |
84 | 84 | ||
85 | public void SetServerInfo(string ServerUrl, string ServerKey) | 85 | public void SetServerInfo(string ServerUrl, string ServerKey) |
86 | { | 86 | { |
87 | this.AssetServerUrl = ServerUrl; | 87 | this.AssetServerUrl = ServerUrl; |
88 | this.AssetSendKey = ServerKey; | 88 | this.AssetSendKey = ServerKey; |
89 | } | 89 | } |
90 | 90 | ||
91 | private void RunRequests() | 91 | private void RunRequests() |
92 | { | 92 | { |
93 | while (true) | 93 | while (true) |
94 | { | 94 | { |
95 | //we need to add support for the asset server not knowing about a requested asset | 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 | 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(); | 97 | ARequest req = this._assetRequests.Dequeue(); |
98 | LLUUID assetID = req.AssetID; | 98 | LLUUID assetID = req.AssetID; |
99 | // OpenSim.Framework.Console.MainLog.Instance.Verbose(" RemoteAssetServer- Got a AssetServer request, processing it - " + this.AssetServerUrl + "assets/" + 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); | 100 | WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "assets/" + assetID); |
101 | WebResponse AssetResponse = AssetLoad.GetResponse(); | 101 | WebResponse AssetResponse = AssetLoad.GetResponse(); |
102 | byte[] idata = new byte[(int)AssetResponse.ContentLength]; | 102 | byte[] idata = new byte[(int)AssetResponse.ContentLength]; |
103 | BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); | 103 | BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream()); |
104 | idata = br.ReadBytes((int)AssetResponse.ContentLength); | 104 | idata = br.ReadBytes((int)AssetResponse.ContentLength); |
105 | br.Close(); | 105 | br.Close(); |
106 | 106 | ||
107 | AssetBase asset = new AssetBase(); | 107 | AssetBase asset = new AssetBase(); |
108 | asset.FullID = assetID; | 108 | asset.FullID = assetID; |
109 | asset.Data = idata; | 109 | asset.Data = idata; |
110 | _receiver.AssetReceived(asset, req.IsTexture); | 110 | _receiver.AssetReceived(asset, req.IsTexture); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | public void Close() | 114 | public void Close() |
115 | { | 115 | { |
116 | 116 | ||
117 | } | 117 | } |
118 | } | 118 | } |
119 | 119 | ||
120 | public class RemoteAssetPlugin : IAssetPlugin | 120 | public class RemoteAssetPlugin : IAssetPlugin |
121 | { | 121 | { |
122 | public RemoteAssetPlugin() | 122 | public RemoteAssetPlugin() |
123 | { | 123 | { |
124 | 124 | ||
125 | } | 125 | } |
126 | 126 | ||
127 | public IAssetServer GetAssetServer() | 127 | public IAssetServer GetAssetServer() |
128 | { | 128 | { |
129 | return (new RemoteAssetServer()); | 129 | return (new RemoteAssetServer()); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | 132 | ||
133 | } | 133 | } |