From 8d1e9f83f338de21482547816834f4535cebf5bc Mon Sep 17 00:00:00 2001
From: MW
Date: Thu, 15 Mar 2007 10:14:12 +0000
Subject: Cleaned up IGridServer interfaces. Added a try/catch around the http
server Startup
---
src/CAPS/SimHttp.cs | 33 +++++++++++++-------
src/GridInterfaces/IGridServer.cs | 37 ++++++++++++++++++-----
src/GridServers/LoginServer.cs | 7 +++--
src/LocalServers/LocalGridServers/LocalGrid.cs | 29 +++++++++---------
src/RemoteServers/RemoteGridServers/RemoteGrid.cs | 23 +++++++-------
5 files changed, 82 insertions(+), 47 deletions(-)
(limited to 'src')
diff --git a/src/CAPS/SimHttp.cs b/src/CAPS/SimHttp.cs
index eb20f3e..12bc9a8 100644
--- a/src/CAPS/SimHttp.cs
+++ b/src/CAPS/SimHttp.cs
@@ -38,6 +38,7 @@ using System.Collections;
using System.Collections.Generic;
using libsecondlife;
using ServerConsole;
+using OpenSim.GridServers;
namespace OpenSim
{
@@ -54,16 +55,23 @@ namespace OpenSim
}
public void StartHTTP() {
- ServerConsole.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK");
- Listener = new HttpListener();
-
- Listener.Prefixes.Add("http://+:" + OpenSim_Main.cfg.IPListenPort + "/");
- Listener.Start();
-
- HttpListenerContext context;
- while(true) {
- context = Listener.GetContext();
- ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
+ try
+ {
+ ServerConsole.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK");
+ Listener = new HttpListener();
+
+ Listener.Prefixes.Add("http://+:" + OpenSim_Main.cfg.IPListenPort + "/");
+ Listener.Start();
+
+ HttpListenerContext context;
+ while(true) {
+ context = Listener.GetContext();
+ ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
+ }
+ }
+ catch (Exception e)
+ {
+ ServerConsole.MainConsole.Instance.WriteLine(e.Message);
}
}
@@ -81,7 +89,10 @@ namespace OpenSim
agent_data.lastname = (string)requestData["lastname"];
agent_data.AgentID = new LLUUID((string)requestData["agent_id"]);
agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
- OpenSim_Main.gridServers.GridServer.agentcircuits.Add((uint)agent_data.circuitcode,agent_data);
+ if (OpenSim_Main.gridServers.GridServer.GetName() == "Remote")
+ {
+ ((RemoteGridBase) OpenSim_Main.gridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode,agent_data);
+ }
return "";
break;
}
diff --git a/src/GridInterfaces/IGridServer.cs b/src/GridInterfaces/IGridServer.cs
index c2d7172..7a43399 100644
--- a/src/GridInterfaces/IGridServer.cs
+++ b/src/GridInterfaces/IGridServer.cs
@@ -46,18 +46,41 @@ namespace OpenSim.GridServers
public interface IGridServer
{
- bool RequestConnection();
- Dictionary agentcircuits {
- get;
- set;
- }
UUIDBlock RequestUUIDBlock();
void RequestNeighbours(); //should return a array of neighbouring regions
AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
+ string GetName();
+ bool RequestConnection();
void SetServerInfo(string ServerUrl, string ServerKey);
- void AddNewSession(Login session); // only used by local version of grid server
- // and didn't use to be part of this interface until we put this in a dll
+ }
+
+ public abstract class RemoteGridBase : IGridServer
+ {
+ public abstract Dictionary agentcircuits {
+ get;
+ set;
+ }
+
+ public abstract UUIDBlock RequestUUIDBlock();
+ public abstract void RequestNeighbours();
+ public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
+ public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
+ public abstract string GetName();
+ public abstract bool RequestConnection();
+ public abstract void SetServerInfo(string ServerUrl, string ServerKey);
+ }
+
+ public abstract class LocalGridBase : IGridServer
+ {
+ public abstract UUIDBlock RequestUUIDBlock();
+ public abstract void RequestNeighbours();
+ public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
+ public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode);
+ public abstract string GetName();
+ public abstract bool RequestConnection();
+ public abstract void SetServerInfo(string ServerUrl, string ServerKey);
+ public abstract void AddNewSession(Login session);
}
public struct UUIDBlock
diff --git a/src/GridServers/LoginServer.cs b/src/GridServers/LoginServer.cs
index da982e7..e678dbf 100644
--- a/src/GridServers/LoginServer.cs
+++ b/src/GridServers/LoginServer.cs
@@ -249,8 +249,11 @@ namespace OpenSim.GridServers
_login.BaseFolder = BaseFolderID;
_login.InventoryFolder = InventoryFolderID;
- //working on local computer so lets add to the gridserver's list of sessions
- this._gridServer.AddNewSession(_login);
+ //working on local computer so lets add to the gridserver's list of sessions?
+ if(OpenSim_Main.gridServers.GridServer.GetName() == "Local")
+ {
+ ((LocalGridBase)this._gridServer).AddNewSession(_login);
+ }
// forward the XML-RPC response to the client
writer.WriteLine("HTTP/1.0 200 OK");
diff --git a/src/LocalServers/LocalGridServers/LocalGrid.cs b/src/LocalServers/LocalGridServers/LocalGrid.cs
index 86a68d5..32ed113 100644
--- a/src/LocalServers/LocalGridServers/LocalGrid.cs
+++ b/src/LocalServers/LocalGridServers/LocalGrid.cs
@@ -110,28 +110,26 @@ namespace LocalGridServers
}
}
- public class LocalGridServer :IGridServer
+ public class LocalGridServer : LocalGridBase
{
public List Sessions = new List();
- private Dictionary AgentCircuits = new Dictionary();
-
- public Dictionary agentcircuits {
- get {return agentcircuits;}
- set {agentcircuits=value;}
- }
-
public LocalGridServer()
{
Sessions = new List();
ServerConsole.MainConsole.Instance.WriteLine("Local Grid Server class created");
}
- public bool RequestConnection()
+ public override string GetName()
+ {
+ return "Local";
+ }
+
+ public override bool RequestConnection()
{
return true;
}
- public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
+ public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
//we are running local
AuthenticateResponse user = new AuthenticateResponse();
@@ -151,31 +149,32 @@ namespace LocalGridServers
return(user);
}
- public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
+ public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
return(true);
}
- public UUIDBlock RequestUUIDBlock()
+ public override UUIDBlock RequestUUIDBlock()
{
UUIDBlock uuidBlock = new UUIDBlock();
return(uuidBlock);
}
- public void RequestNeighbours()
+ public override void RequestNeighbours()
{
return;
}
- public void SetServerInfo(string ServerUrl, string ServerKey)
+ public override void SetServerInfo(string ServerUrl, string ServerKey)
{
}
+
///
/// used by the local login server to inform us of new sessions
///
///
- public void AddNewSession(Login session)
+ public override void AddNewSession(Login session)
{
lock(this.Sessions)
{
diff --git a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
index 26cd137..17b6440 100644
--- a/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
+++ b/src/RemoteServers/RemoteGridServers/RemoteGrid.cs
@@ -65,13 +65,13 @@ namespace RemoteGridServers
return(new RemoteAssetServer());
}
}
- public class RemoteGridServer :IGridServer
+ public class RemoteGridServer : RemoteGridBase
{
private string GridServerUrl;
private string GridSendKey;
private Dictionary AgentCircuits = new Dictionary();
- public Dictionary agentcircuits {
+ public override Dictionary agentcircuits {
get {return AgentCircuits;}
set {AgentCircuits=value;}
}
@@ -81,13 +81,12 @@ namespace RemoteGridServers
ServerConsole.MainConsole.Instance.WriteLine("Remote Grid Server class created");
}
- public bool RequestConnection()
+ public override bool RequestConnection()
{
return true;
}
-
- public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
+ public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode)
{
agentcircuitdata validcircuit=this.AgentCircuits[circuitcode];
AuthenticateResponse user = new AuthenticateResponse();
@@ -110,7 +109,7 @@ namespace RemoteGridServers
return(user);
}
- public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
+ public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode)
{
WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString());
DeleteSession.Method="DELETE";
@@ -127,26 +126,26 @@ namespace RemoteGridServers
return(true);
}
- public UUIDBlock RequestUUIDBlock()
+ public override UUIDBlock RequestUUIDBlock()
{
UUIDBlock uuidBlock = new UUIDBlock();
return(uuidBlock);
}
- public void RequestNeighbours()
+ public override void RequestNeighbours()
{
return;
}
- public void SetServerInfo(string ServerUrl, string ServerKey)
+ public override void SetServerInfo(string ServerUrl, string ServerKey)
{
this.GridServerUrl = ServerUrl;
this.GridSendKey = ServerKey;
}
- public void AddNewSession(Login session)
- {
-
+ public override string GetName()
+ {
+ return "Remote";
}
}
--
cgit v1.1