aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs')
-rw-r--r--ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs241
1 files changed, 0 insertions, 241 deletions
diff --git a/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs b/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
deleted file mode 100644
index f7c33e8..0000000
--- a/ConvertToPlugins/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
+++ /dev/null
@@ -1,241 +0,0 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27using System;
28using System.Collections.Generic;
29using System.Threading;
30using System.Net;
31using System.Net.Sockets;
32using System.IO;
33using libsecondlife;
34using OpenSim.GridServers;
35
36namespace RemoteGridServers
37{
38 /// <summary>
39 ///
40 /// </summary>
41 ///
42
43 public class RemoteGridPlugin : IGridPlugin
44 {
45 public RemoteGridPlugin()
46 {
47
48 }
49
50 public IGridServer GetGridServer()
51 {
52 return(new RemoteGridServer());
53 }
54 }
55
56 public class RemoteAssetPlugin : IAssetPlugin
57 {
58 public RemoteAssetPlugin()
59 {
60
61 }
62
63 public IAssetServer GetAssetServer()
64 {
65 return(new RemoteAssetServer());
66 }
67 }
68 public class RemoteGridServer :IGridServer
69 {
70 private string GridServerUrl;
71 private string GridSendKey;
72
73 public RemoteGridServer()
74 {
75 ServerConsole.MainConsole.Instance.WriteLine("Remote Grid Server class created");
76 }
77
78 public bool RequestConnection()
79 {
80 return true;
81 }
82 public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
83 {
84 AuthenticateResponse user = new AuthenticateResponse();
85
86 WebRequest CheckSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + "/" + circuitCode.ToString() + "/exists");
87 WebResponse GridResponse = CheckSession.GetResponse();
88 StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
89 String grTest = sr.ReadLine();
90 sr.Close();
91 GridResponse.Close();
92 if(String.IsNullOrEmpty(grTest) || grTest.Equals("1"))
93 {
94 // YAY! Valid login
95 user.Authorised = true;
96 user.LoginInfo = new Login();
97 user.LoginInfo.Agent = agentID;
98 user.LoginInfo.Session = sessionID;
99 user.LoginInfo.First = "";
100 user.LoginInfo.Last = "";
101
102 }
103 else
104 {
105 // Invalid
106 user.Authorised = false;
107 }
108
109 return(user);
110 }
111
112 public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
113 {
114 WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + GridSendKey + "/" + agentID.ToString() + circuitCode.ToString() + "/delete");
115 WebResponse GridResponse = DeleteSession.GetResponse();
116 StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
117 String grTest = sr.ReadLine();
118 sr.Close();
119 GridResponse.Close();
120 ServerConsole.MainConsole.Instance.WriteLine("DEBUG: " + grTest);
121 return(true);
122 }
123
124 public UUIDBlock RequestUUIDBlock()
125 {
126 UUIDBlock uuidBlock = new UUIDBlock();
127 return(uuidBlock);
128 }
129
130 public void RequestNeighbours()
131 {
132 return;
133 }
134
135 public void SetServerInfo(string ServerUrl, string ServerKey)
136 {
137 this.GridServerUrl = ServerUrl;
138 this.GridSendKey = ServerKey;
139 }
140
141 public void AddNewSession(Login session)
142 {
143
144 }
145 }
146
147
148 public class RemoteAssetServer : IAssetServer
149 {
150 private IAssetReceiver _receiver;
151 private BlockingQueue<ARequest> _assetRequests;
152 private Thread _remoteAssetServerThread;
153 private string AssetServerUrl;
154 private string AssetSendKey;
155
156 public RemoteAssetServer()
157 {
158 this._assetRequests = new BlockingQueue<ARequest>();
159 this._remoteAssetServerThread = new Thread(new ThreadStart(RunRequests));
160 this._remoteAssetServerThread.IsBackground = true;
161 this._remoteAssetServerThread.Start();
162 ServerConsole.MainConsole.Instance.WriteLine("Remote Asset Server class created");
163 }
164
165 public void SetReceiver(IAssetReceiver receiver)
166 {
167 this._receiver = receiver;
168 }
169
170 public void RequestAsset(LLUUID assetID, bool isTexture)
171 {
172 ARequest req = new ARequest();
173 req.AssetID = assetID;
174 req.IsTexture = isTexture;
175 this._assetRequests.Enqueue(req);
176 }
177
178 public void UpdateAsset(AssetBase asset)
179 {
180
181 }
182
183 public void UploadNewAsset(AssetBase asset)
184 {
185
186 }
187
188 public void SetServerInfo(string ServerUrl, string ServerKey)
189 {
190 this.AssetServerUrl = ServerUrl;
191 this.AssetSendKey = ServerKey;
192 }
193
194 private void RunRequests()
195 {
196 while(true)
197 {
198 //we need to add support for the asset server not knowing about a requested asset
199 ARequest req = this._assetRequests.Dequeue();
200 LLUUID assetID = req.AssetID;
201 ServerConsole.MainConsole.Instance.WriteLine(" RemoteAssetServer- Got a AssetServer request, processing it");
202 WebRequest AssetLoad = WebRequest.Create(this.AssetServerUrl + "getasset/" + AssetSendKey + "/" + assetID + "/data");
203 WebResponse AssetResponse = AssetLoad.GetResponse();
204 byte[] idata = new byte[(int)AssetResponse.ContentLength];
205 BinaryReader br = new BinaryReader(AssetResponse.GetResponseStream());
206 idata = br.ReadBytes((int)AssetResponse.ContentLength);
207 br.Close();
208
209 AssetBase asset = new AssetBase();
210 asset.FullID = assetID;
211 asset.Data = idata;
212 _receiver.AssetReceived(asset, req.IsTexture );
213 }
214 }
215 }
216
217 public class BlockingQueue< T > {
218 private Queue< T > _queue = new Queue< T >();
219 private object _queueSync = new object();
220
221 public void Enqueue(T value)
222 {
223 lock(_queueSync)
224 {
225 _queue.Enqueue(value);
226 Monitor.Pulse(_queueSync);
227 }
228 }
229
230 public T Dequeue()
231 {
232 lock(_queueSync)
233 {
234 if( _queue.Count < 1)
235 Monitor.Wait(_queueSync);
236
237 return _queue.Dequeue();
238 }
239 }
240 }
241}