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