Cleaned up IGridServer interfaces.

Added a try/catch around the http server Startup
adam
MW 2007-03-15 10:14:12 +00:00
parent 7c925fb607
commit 8d1e9f83f3
5 changed files with 80 additions and 45 deletions

View File

@ -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();
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();
Listener.Prefixes.Add("http://+:" + OpenSim_Main.cfg.IPListenPort + "/");
Listener.Start();
HttpListenerContext context;
while(true) {
context = Listener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
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 "<?xml version=\"1.0\"?><methodResponse><params /></methodResponse>";
break;
}

View File

@ -46,18 +46,41 @@ namespace OpenSim.GridServers
public interface IGridServer
{
bool RequestConnection();
Dictionary<uint, agentcircuitdata> 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<uint, agentcircuitdata> 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

View File

@ -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");

View File

@ -110,28 +110,26 @@ namespace LocalGridServers
}
}
public class LocalGridServer :IGridServer
public class LocalGridServer : LocalGridBase
{
public List<Login> Sessions = new List<Login>();
private Dictionary<uint, agentcircuitdata> AgentCircuits = new Dictionary<uint, agentcircuitdata>();
public Dictionary<uint, agentcircuitdata> agentcircuits {
get {return agentcircuits;}
set {agentcircuits=value;}
}
public LocalGridServer()
{
Sessions = new List<Login>();
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)
{
}
/// <summary>
/// used by the local login server to inform us of new sessions
/// </summary>
/// <param name="session"></param>
public void AddNewSession(Login session)
public override void AddNewSession(Login session)
{
lock(this.Sessions)
{

View File

@ -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<uint, agentcircuitdata> AgentCircuits = new Dictionary<uint, agentcircuitdata>();
public Dictionary<uint, agentcircuitdata> agentcircuits {
public override Dictionary<uint, agentcircuitdata> 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";
}
}