aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-07-11 08:02:47 +0000
committerAdam Frisby2007-07-11 08:02:47 +0000
commit5c7ffdde0b9642a42e8f5987e06eb01220ff7776 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs
parentWho would have known that the only way of specifying utf-8 without preamble, ... (diff)
downloadopensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.zip
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.gz
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.bz2
opensim-SC-5c7ffdde0b9642a42e8f5987e06eb01220ff7776.tar.xz
* Wiping trunk in prep for Sugilite
Diffstat (limited to 'OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs')
-rw-r--r--OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs212
1 files changed, 0 insertions, 212 deletions
diff --git a/OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs b/OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs
deleted file mode 100644
index 7c93d43..0000000
--- a/OpenSim/OpenSim.GridInterfaces/Remote/RemoteGridServer.cs
+++ /dev/null
@@ -1,212 +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;
30using System.Collections.Generic;
31using System.Threading;
32using System.Net;
33using System.Net.Sockets;
34using System.IO;
35using libsecondlife;
36using Nwc.XmlRpc;
37using OpenSim.Framework.Interfaces;
38using OpenSim.Framework.Types;
39using OpenSim.Framework.Console;
40
41namespace OpenSim.GridInterfaces.Remote
42{
43 public class RemoteGridServer : RemoteGridBase
44 {
45 private string GridServerUrl;
46 private string GridSendKey;
47 private string GridRecvKey;
48 private Dictionary<uint, AgentCircuitData> AgentCircuits = new Dictionary<uint, AgentCircuitData>();
49 private ArrayList simneighbours = new ArrayList();
50 private Hashtable griddatahash;
51
52 public override Dictionary<uint, AgentCircuitData> agentcircuits
53 {
54 get { return AgentCircuits; }
55 set { AgentCircuits = value; }
56 }
57
58 public override ArrayList neighbours
59 {
60 get { return simneighbours; }
61 set { simneighbours = value; }
62 }
63
64 public override Hashtable GridData
65 {
66 get { return griddatahash; }
67 set { griddatahash = value; }
68 }
69
70
71 public RemoteGridServer()
72 {
73 MainConsole.Instance.Notice("Remote Grid Server class created");
74 }
75
76 public override bool RequestConnection(LLUUID SimUUID, string sim_ip, uint sim_port)
77 {
78 Hashtable GridParams = new Hashtable();
79 GridParams["authkey"] = GridSendKey;
80 GridParams["UUID"] = SimUUID.ToString();
81 GridParams["sim_ip"] = sim_ip;
82 GridParams["sim_port"] = sim_port.ToString();
83 ArrayList SendParams = new ArrayList();
84 SendParams.Add(GridParams);
85
86 XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
87 XmlRpcResponse GridResp = GridReq.Send(this.GridServerUrl, 3000);
88 Hashtable GridRespData = (Hashtable)GridResp.Value;
89 this.griddatahash = GridRespData;
90
91 if (GridRespData.ContainsKey("error"))
92 {
93 string errorstring = (string)GridRespData["error"];
94 MainConsole.Instance.Warn("Error connecting to grid:");
95 MainConsole.Instance.Warn(errorstring);
96 return false;
97 }
98 this.neighbours = (ArrayList)GridRespData["neighbours"];
99 Console.WriteLine(simneighbours.Count);
100 return true;
101 }
102
103 public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
104 {
105 AgentCircuitData validcircuit = null;
106 if (this.AgentCircuits.ContainsKey(circuitcode))
107 {
108 validcircuit = this.AgentCircuits[circuitcode];
109 }
110 AuthenticateResponse user = new AuthenticateResponse();
111 if (validcircuit == null)
112 {
113 //don't have this circuit code in our list
114 user.Authorised = false;
115 return (user);
116 }
117
118 if ((sessionID == validcircuit.SessionID) && (agentID == validcircuit.AgentID))
119 {
120 // YAY! Valid login
121 user.Authorised = true;
122 user.LoginInfo = new Login();
123 user.LoginInfo.Agent = agentID;
124 user.LoginInfo.Session = sessionID;
125 user.LoginInfo.SecureSession = validcircuit.SecureSessionID;
126 user.LoginInfo.First = validcircuit.firstname;
127 user.LoginInfo.Last = validcircuit.lastname;
128 }
129 else
130 {
131 // Invalid
132 user.Authorised = false;
133 }
134
135 return (user);
136 }
137
138 public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
139 {
140 WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString());
141 DeleteSession.Method = "DELETE";
142 DeleteSession.ContentType = "text/plaintext";
143 DeleteSession.ContentLength = 0;
144
145 StreamWriter stOut = new StreamWriter(DeleteSession.GetRequestStream(), System.Text.Encoding.ASCII);
146 stOut.Write("");
147 stOut.Close();
148
149 StreamReader stIn = new StreamReader(DeleteSession.GetResponse().GetResponseStream());
150 string GridResponse = stIn.ReadToEnd();
151 stIn.Close();
152 return (true);
153 }
154
155 public override UUIDBlock RequestUUIDBlock()
156 {
157 UUIDBlock uuidBlock = new UUIDBlock();
158 return (uuidBlock);
159 }
160
161 public override NeighbourInfo[] RequestNeighbours()
162 {
163 return null;
164 }
165
166 public override IList RequestMapBlocks(int minX, int minY, int maxX, int maxY)
167 {
168 Hashtable param = new Hashtable();
169 param["xmin"] = minX;
170 param["ymin"] = minY;
171 param["xmax"] = maxX;
172 param["ymax"] = maxY;
173 IList parameters = new ArrayList();
174 parameters.Add(param);
175 XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
176 XmlRpcResponse resp = req.Send(GridServerUrl, 3000);
177 Hashtable respData = (Hashtable)resp.Value;
178 return (IList)respData["sim-profiles"];
179 }
180
181 public override void SetServerInfo(string ServerUrl, string SendKey, string RecvKey)
182 {
183 this.GridServerUrl = ServerUrl;
184 this.GridSendKey = SendKey;
185 this.GridRecvKey = RecvKey;
186 }
187
188 public override string GetName()
189 {
190 return "Remote";
191 }
192
193 public override void Close()
194 {
195
196 }
197 }
198
199 public class RemoteGridPlugin : IGridPlugin
200 {
201 public RemoteGridPlugin()
202 {
203
204 }
205
206 public IGridServer GetGridServer()
207 {
208 return (new RemoteGridServer());
209 }
210 }
211
212}