Added sandbox mode and setup facility

adam
gareth 2007-03-05 17:44:59 +00:00
parent ea28985d05
commit 560b46357e
2 changed files with 113 additions and 43 deletions

View File

@ -53,25 +53,81 @@ namespace OpenSim
public int IPListenPort; public int IPListenPort;
public string IPListenAddr; public string IPListenAddr;
public string AssetURL; public bool sandbox;
public string AssetSendKey; public string AssetURL="";
public string AssetSendKey="";
public string GridURL; public string GridURL="";
public string GridSendKey; public string GridSendKey="";
private IObjectContainer db; private IObjectContainer db;
public void LoadDefaults() { public void LoadDefaults() {
this.RegionName = "OpenSim test\0"; string tempstring;
Console.WriteLine("Config.cs:LoadDefaults() - Please press enter to retain default or enter new settings");
Console.Write("Name [OpenSim test]:");
tempstring=Console.ReadLine();
if(tempstring=="") {
this.RegionName = "OpenSim test";
} else {
this.RegionName = tempstring;
}
Console.Write("Grid location X [997]:");
tempstring=Console.ReadLine();
if(tempstring=="") {
this.RegionLocX = 997; this.RegionLocX = 997;
} else {
this.RegionLocX = (uint)Convert.ToInt32(tempstring);
}
Console.Write("Grid location Y [996]:");
tempstring=Console.ReadLine();
if(tempstring=="") {
this.RegionLocY = 996; this.RegionLocY = 996;
this.RegionHandle = Helpers.UIntsToLong((RegionLocX*256), (RegionLocY*256)); } else {
this.RegionLocY = (uint)Convert.ToInt32(tempstring);
}
Console.Write("Listen on UDP port for client connections [9000]:");
tempstring=Console.ReadLine();
if(tempstring=="") {
this.IPListenPort = 9000; this.IPListenPort = 9000;
this.IPListenAddr = "4.78.190.75"; } else {
this.AssetURL = "http://www.osgrid.org/ogs/assetserver/"; this.IPListenPort = Convert.ToInt32(tempstring);
this.AssetSendKey = "1234"; }
this.GridURL = "http://www.osgrid.org/ogs/gridserver/";
this.GridSendKey = "1234"; Console.Write("Listen on IP address for client connections [127.0.0.1]:");
tempstring=Console.ReadLine();
if(tempstring=="") {
this.IPListenAddr = "127.0.0.1";
} else {
this.IPListenAddr = tempstring;
}
Console.Write("Run in sandbox or grid mode? [sandbox]:");
tempstring=Console.ReadLine();
if(tempstring=="") {
this.sandbox = true;
} else if(tempstring=="grid"){
this.sandbox = false;
} else if(tempstring=="sandbox"){
this.sandbox=true;
}
if(!this.sandbox) {
Console.Write("Asset server URL:");
this.AssetURL=Console.ReadLine();
Console.Write("Key to send to asset server:");
this.AssetSendKey=Console.ReadLine();
Console.Write("Grid server URL:");
this.GridURL=Console.ReadLine();
Console.Write("Key to send to gridserver:");
this.GridSendKey=Console.ReadLine();
}
this.RegionHandle = Helpers.UIntsToLong((RegionLocX*256), (RegionLocY*256));
} }
public void InitConfig() { public void InitConfig() {
@ -103,20 +159,30 @@ namespace OpenSim
Console.WriteLine("Config.cs:InitConfig() - Exception occured"); Console.WriteLine("Config.cs:InitConfig() - Exception occured");
Console.WriteLine(e.ToString()); Console.WriteLine(e.ToString());
} }
Console.WriteLine("Sim settings loaded:");
Console.WriteLine("Name: " + this.RegionName);
Console.WriteLine("Region Location: [" + this.RegionLocX.ToString() + "," + this.RegionLocY + "]");
Console.WriteLine("Region Handle: " + this.RegionHandle.ToString());
Console.WriteLine("Listening on IP: " + this.IPListenAddr + ":" + this.IPListenPort);
Console.WriteLine("Sandbox Mode? " + this.sandbox.ToString());
Console.WriteLine("Asset URL: " + this.AssetURL);
Console.WriteLine("Asset key: " + this.AssetSendKey);
Console.WriteLine("Grid URL: " + this.GridURL);
Console.WriteLine("Grid key: " + this.GridSendKey);
} }
public World LoadWorld() { public World LoadWorld() {
Console.WriteLine("Config.cs:LoadWorld() - Looking for a world object in local DB"); Console.WriteLine("Config.cs:LoadWorld() - Looking for a world object in local DB");
// IObjectSet world_result = db.Get(typeof(OpenSim.world.World)); // IObjectSet world_result = db.Get(typeof(OpenSim.world.World));
// if(world_result.Count==1) { // if(world_result.Count==1) {
Console.WriteLine("Config.cs:LoadWorld() - Found an OpenSim.world.World object in local database, loading"); // Console.WriteLine("Config.cs:LoadWorld() - Found an OpenSim.world.World object in local database, loading");
//return (World)world_result.Next(); //return (World)world_result.Next();
// } else { // } else {
Console.WriteLine("Config.cs:LoadWorld() - Could not find the world or too many worlds! Constructing blank one"); Console.WriteLine("Config.cs:LoadWorld() - Could not find the world or too many worlds! Constructing blank one");
World blank = new World(); World blank = new World();
Console.WriteLine("Config.cs:LoadWorld() - Saving initial world state to disk"); Console.WriteLine("Config.cs:LoadWorld() - Saving initial world state to disk");
db.Set(blank); //db.Set(blank);
db.Commit(); //db.Commit();
return blank; return blank;
// } // }
} }
@ -124,14 +190,6 @@ namespace OpenSim
public void LoadFromGrid() { public void LoadFromGrid() {
Console.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!"); Console.WriteLine("Config.cs:LoadFromGrid() - dummy function, DOING ABSOLUTELY NOTHING AT ALL!!!");
// TODO: Make this crap work // TODO: Make this crap work
/* WebRequest GridLogin = WebRequest.Create(this.GridURL + "regions/" + this.RegionHandle.ToString() + "/login");
WebResponse GridResponse = GridLogin.GetResponse();
byte[] idata = new byte[(int)GridResponse.ContentLength];
BinaryReader br = new BinaryReader(GridResponse.GetResponseStream());
br.Close();
GridResponse.Close();
*/
} }
public void Shutdown() { public void Shutdown() {

View File

@ -80,6 +80,7 @@ namespace OpenSim
} }
public void AssetLoader() { public void AssetLoader() {
if(OpenSim_Main.cfg.sandbox==false) {
Console.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread"); Console.WriteLine("OpenSimClient.cs:AssetLoader() - Starting new thread");
TransferRequestPacket reqPacket = AssetRequests.Dequeue(); TransferRequestPacket reqPacket = AssetRequests.Dequeue();
Console.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it"); Console.WriteLine("OpenSimClient.cs:AssetLoader() - Got a request, processing it");
@ -129,6 +130,7 @@ namespace OpenSim
} }
AssetResponse.Close(); AssetResponse.Close();
} }
}
public void ProcessInPacket(Packet Pack) { public void ProcessInPacket(Packet Pack) {
ack_pack(Pack); ack_pack(Pack);
@ -156,6 +158,8 @@ namespace OpenSim
lock(OpenSim_Main.local_world.Entities) { lock(OpenSim_Main.local_world.Entities) {
OpenSim_Main.local_world.Entities.Remove(this.AgentID); OpenSim_Main.local_world.Entities.Remove(this.AgentID);
} }
if(OpenSim_Main.cfg.sandbox==false) {
WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete"); WebRequest DeleteSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + this.AgentID.ToString() + this.CircuitCode.ToString() + "/delete");
WebResponse GridResponse = DeleteSession.GetResponse(); WebResponse GridResponse = DeleteSession.GetResponse();
StreamReader sr = new StreamReader(GridResponse.GetResponseStream()); StreamReader sr = new StreamReader(GridResponse.GetResponseStream());
@ -163,7 +167,7 @@ namespace OpenSim
sr.Close(); sr.Close();
GridResponse.Close(); GridResponse.Close();
Console.WriteLine("DEBUG: " + grTest); Console.WriteLine("DEBUG: " + grTest);
}
this.ClientThread.Abort(); this.ClientThread.Abort();
break; break;
case PacketType.AgentUpdate: case PacketType.AgentUpdate:
@ -426,6 +430,7 @@ namespace OpenSim
} }
private void AuthUser() { private void AuthUser() {
if(OpenSim_Main.cfg.sandbox==false) {
Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid"); Console.WriteLine("OpenSimClient.cs:AuthUser() - Authenticating new user request with grid");
WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists"); WebRequest CheckSession = WebRequest.Create(OpenSim_Main.cfg.GridURL + "/usersessions/" + OpenSim_Main.cfg.GridSendKey + "/" + cirpack.CircuitCode.ID.ToString() + "/" + cirpack.CircuitCode.Code.ToString() + "/exists");
Console.WriteLine(OpenSim_Main.cfg.GridURL); Console.WriteLine(OpenSim_Main.cfg.GridURL);
@ -445,6 +450,13 @@ namespace OpenSim
Console.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString()); Console.WriteLine("OpenSimClient.cs:AuthUser() - New user request denied to " + userEP.ToString());
ClientThread.Abort(); ClientThread.Abort();
} }
} else {
this.AgentID=cirpack.CircuitCode.ID;
this.SessionID=cirpack.CircuitCode.SessionID;
this.CircuitCode=cirpack.CircuitCode.Code;
InitNewClient();
ClientLoop();
}
} }
} }