aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/RegionInfo.cs
diff options
context:
space:
mode:
authorMW2007-05-24 12:35:32 +0000
committerMW2007-05-24 12:35:32 +0000
commitf95b6081cba084d1b067acea99c0effa2b3bf42c (patch)
tree7a7ab4aa037f75afa54f403c701a735acb101575 /OpenSim/OpenSim.RegionServer/RegionInfo.cs
parentDie ServiceManager! (Not really Gareth, just the old directory, new directory... (diff)
downloadopensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.zip
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.gz
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.bz2
opensim-SC-f95b6081cba084d1b067acea99c0effa2b3bf42c.tar.xz
Renamed the new Directories. (removed the "-Source" from the end of them)
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/RegionInfo.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/RegionInfo.cs261
1 files changed, 261 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.RegionServer/RegionInfo.cs b/OpenSim/OpenSim.RegionServer/RegionInfo.cs
new file mode 100644
index 0000000..f82495a
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/RegionInfo.cs
@@ -0,0 +1,261 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.Net;
5using System.Web;
6using System.IO;
7using OpenSim.Framework.Interfaces;
8using OpenSim.Framework.Utilities;
9using libsecondlife;
10
11namespace OpenSim
12{
13 public class RegionInfo : RegionInfoBase
14 {
15 //following should be removed and the GenericConfig object passed around,
16 //so each class (AssetServer, GridServer etc) can access what config data they want
17 public string AssetURL = "http://127.0.0.1:8003/";
18 public string AssetSendKey = "";
19
20 public string GridURL = "";
21 public string GridSendKey = "";
22 public string GridRecvKey = "";
23 public string UserURL = "";
24 public string UserSendKey = "";
25 public string UserRecvKey = "";
26 private bool isSandbox;
27
28 public string DataStore;
29
30 public RegionInfo()
31 {
32
33 }
34
35 public void SaveToGrid()
36 {
37 //we really want to keep any server connection code out of here and out of the code code
38 // and put it in the server connection classes (those inheriting from IGridServer etc)
39 string reqtext;
40 reqtext = "<Root>";
41 reqtext += "<authkey>" + this.GridSendKey + "</authkey>";
42 reqtext += "<sim>";
43 reqtext += "<uuid>" + this.SimUUID.ToString() + "</uuid>";
44 reqtext += "<regionname>" + this.RegionName + "</regionname>";
45 reqtext += "<sim_ip>" + this.IPListenAddr + "</sim_ip>";
46 reqtext += "<sim_port>" + this.IPListenPort.ToString() + "</sim_port>";
47 reqtext += "<region_locx>" + this.RegionLocX.ToString() + "</region_locx>";
48 reqtext += "<region_locy>" + this.RegionLocY.ToString() + "</region_locy>";
49 reqtext += "<estate_id>1</estate_id>";
50 reqtext += "</sim>";
51 reqtext += "</Root>";
52
53 byte[] reqdata = (new System.Text.ASCIIEncoding()).GetBytes(reqtext);
54 string newpath = "";
55 if (this.GridURL.EndsWith("/"))
56 {
57 newpath = this.GridURL + "sims/";
58 }
59 else
60 {
61 newpath = this.GridURL + "/sims/";
62 }
63
64 WebRequest GridSaveReq = WebRequest.Create(newpath + this.SimUUID.ToString());
65 GridSaveReq.Method = "POST";
66 GridSaveReq.ContentType = "application/x-www-form-urlencoded";
67 GridSaveReq.ContentLength = reqdata.Length;
68
69 Stream stOut = GridSaveReq.GetRequestStream();
70 stOut.Write(reqdata, 0, reqdata.Length);
71 stOut.Close();
72
73 WebResponse gridresp = GridSaveReq.GetResponse();
74 StreamReader stIn = new StreamReader(gridresp.GetResponseStream(), Encoding.ASCII);
75 string GridResponse = stIn.ReadToEnd();
76 stIn.Close();
77 gridresp.Close();
78
79 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"RegionInfo.CS:SaveToGrid() - Grid said: " + GridResponse);
80 }
81
82 public void InitConfig(bool sandboxMode, IGenericConfig configData)
83 {
84 this.isSandbox = sandboxMode;
85 try
86 {
87 // Sim UUID
88 string attri = "";
89 attri = configData.GetAttribute("SimUUID");
90 if (attri == "")
91 {
92 this.SimUUID = LLUUID.Random();
93 configData.SetAttribute("SimUUID", this.SimUUID.ToString());
94 }
95 else
96 {
97 this.SimUUID = new LLUUID(attri);
98 }
99
100 // Sim name
101 attri = "";
102 attri = configData.GetAttribute("SimName");
103 if (attri == "")
104 {
105 this.RegionName = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Name", "OpenSim test");
106 configData.SetAttribute("SimName", this.RegionName);
107 }
108 else
109 {
110 this.RegionName = attri;
111 }
112 // Sim/Grid location X
113 attri = "";
114 attri = configData.GetAttribute("SimLocationX");
115 if (attri == "")
116 {
117 string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location X", "997");
118 configData.SetAttribute("SimLocationX", location);
119 this.RegionLocX = (uint)Convert.ToUInt32(location);
120 }
121 else
122 {
123 this.RegionLocX = (uint)Convert.ToUInt32(attri);
124 }
125 // Sim/Grid location Y
126 attri = "";
127 attri = configData.GetAttribute("SimLocationY");
128 if (attri == "")
129 {
130 string location = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid Location Y", "996");
131 configData.SetAttribute("SimLocationY", location);
132 this.RegionLocY = (uint)Convert.ToUInt32(location);
133 }
134 else
135 {
136 this.RegionLocY = (uint)Convert.ToUInt32(attri);
137 }
138
139 // Local storage datastore
140 attri = "";
141 attri = configData.GetAttribute("Datastore");
142 if (attri == "")
143 {
144 string datastore = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Filename for local storage", "localworld.yap");
145 configData.SetAttribute("Datastore", datastore);
146 this.DataStore = datastore;
147 }
148 else
149 {
150 this.DataStore = attri;
151 }
152
153 //Sim Listen Port
154 attri = "";
155 attri = configData.GetAttribute("SimListenPort");
156 if (attri == "")
157 {
158 string port = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("UDP port for client connections", "9000");
159 configData.SetAttribute("SimListenPort", port);
160 this.IPListenPort = Convert.ToInt32(port);
161 }
162 else
163 {
164 this.IPListenPort = Convert.ToInt32(attri);
165 }
166 //Sim Listen Address
167 attri = "";
168 attri = configData.GetAttribute("SimListenAddress");
169 if (attri == "")
170 {
171 this.IPListenAddr = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("IP Address to listen on for client connections", "127.0.0.1");
172 configData.SetAttribute("SimListenAddress", this.IPListenAddr);
173 }
174 else
175 {
176 this.IPListenAddr = attri;
177 }
178
179 if (!isSandbox)
180 {
181 //shouldn't be reading this data in here, it should be up to the classes implementing the server interfaces to read what they need from the config object
182
183 //Grid Server URL
184 attri = "";
185 attri = configData.GetAttribute("GridServerURL");
186 if (attri == "")
187 {
188 this.GridURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Grid server URL","http://127.0.0.1:8001/");
189 configData.SetAttribute("GridServerURL", this.GridURL);
190 }
191 else
192 {
193 this.GridURL = attri;
194 }
195
196 //Grid Send Key
197 attri = "";
198 attri = configData.GetAttribute("GridSendKey");
199 if (attri == "")
200 {
201 this.GridSendKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to send to grid server","null");
202 configData.SetAttribute("GridSendKey", this.GridSendKey);
203 }
204 else
205 {
206 this.GridSendKey = attri;
207 }
208
209 //Grid Receive Key
210 attri = "";
211 attri = configData.GetAttribute("GridRecvKey");
212 if (attri == "")
213 {
214 this.GridRecvKey = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Key to expect from grid server","null");
215 configData.SetAttribute("GridRecvKey", this.GridRecvKey);
216 }
217 else
218 {
219 this.GridRecvKey = attri;
220 }
221
222 attri = "";
223 attri = configData.GetAttribute("AssetServerURL");
224 if (attri == "")
225 {
226 this.AssetURL = OpenSim.Framework.Console.MainConsole.Instance.CmdPrompt("Asset server URL", "http://127.0.0.1:8003/");
227 configData.SetAttribute("AssetServerURL", this.GridURL);
228 }
229 else
230 {
231 this.AssetURL = attri;
232 }
233
234 }
235 this.RegionHandle = Util.UIntsToLong((RegionLocX * 256), (RegionLocY * 256));
236 if (!this.isSandbox)
237 {
238 this.SaveToGrid();
239 }
240 configData.Commit();
241 }
242 catch (Exception e)
243 {
244 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,"Config.cs:InitConfig() - Exception occured");
245 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.MEDIUM,e.ToString());
246 }
247
248 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Sim settings loaded:");
249 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "UUID: " + this.SimUUID.ToStringHyphenated());
250 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Name: " + this.RegionName);
251 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
252 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Region Handle: " + this.RegionHandle.ToString());
253 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
254 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Sandbox Mode? " + isSandbox.ToString());
255 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Asset URL: " + this.AssetURL);
256 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Asset key: " + this.AssetSendKey);
257 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Grid URL: " + this.GridURL);
258 OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Grid key: " + this.GridSendKey);
259 }
260 }
261}