diff options
author | MW | 2007-03-15 10:14:12 +0000 |
---|---|---|
committer | MW | 2007-03-15 10:14:12 +0000 |
commit | 8d1e9f83f338de21482547816834f4535cebf5bc (patch) | |
tree | b09bb3a9e1ba4eff9032929b0c3b99cbe08b9965 | |
parent | Added simple mono/nant instructions (diff) | |
download | opensim-SC-8d1e9f83f338de21482547816834f4535cebf5bc.zip opensim-SC-8d1e9f83f338de21482547816834f4535cebf5bc.tar.gz opensim-SC-8d1e9f83f338de21482547816834f4535cebf5bc.tar.bz2 opensim-SC-8d1e9f83f338de21482547816834f4535cebf5bc.tar.xz |
Cleaned up IGridServer interfaces.
Added a try/catch around the http server Startup
-rw-r--r-- | src/CAPS/SimHttp.cs | 33 | ||||
-rw-r--r-- | src/GridInterfaces/IGridServer.cs | 37 | ||||
-rw-r--r-- | src/GridServers/LoginServer.cs | 7 | ||||
-rw-r--r-- | src/LocalServers/LocalGridServers/LocalGrid.cs | 29 | ||||
-rw-r--r-- | src/RemoteServers/RemoteGridServers/RemoteGrid.cs | 23 |
5 files changed, 82 insertions, 47 deletions
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; | |||
38 | using System.Collections.Generic; | 38 | using System.Collections.Generic; |
39 | using libsecondlife; | 39 | using libsecondlife; |
40 | using ServerConsole; | 40 | using ServerConsole; |
41 | using OpenSim.GridServers; | ||
41 | 42 | ||
42 | namespace OpenSim | 43 | namespace OpenSim |
43 | { | 44 | { |
@@ -54,16 +55,23 @@ namespace OpenSim | |||
54 | } | 55 | } |
55 | 56 | ||
56 | public void StartHTTP() { | 57 | public void StartHTTP() { |
57 | ServerConsole.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK"); | 58 | try |
58 | Listener = new HttpListener(); | 59 | { |
59 | 60 | ServerConsole.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK"); | |
60 | Listener.Prefixes.Add("http://+:" + OpenSim_Main.cfg.IPListenPort + "/"); | 61 | Listener = new HttpListener(); |
61 | Listener.Start(); | 62 | |
62 | 63 | Listener.Prefixes.Add("http://+:" + OpenSim_Main.cfg.IPListenPort + "/"); | |
63 | HttpListenerContext context; | 64 | Listener.Start(); |
64 | while(true) { | 65 | |
65 | context = Listener.GetContext(); | 66 | HttpListenerContext context; |
66 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); | 67 | while(true) { |
68 | context = Listener.GetContext(); | ||
69 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); | ||
70 | } | ||
71 | } | ||
72 | catch (Exception e) | ||
73 | { | ||
74 | ServerConsole.MainConsole.Instance.WriteLine(e.Message); | ||
67 | } | 75 | } |
68 | } | 76 | } |
69 | 77 | ||
@@ -81,7 +89,10 @@ namespace OpenSim | |||
81 | agent_data.lastname = (string)requestData["lastname"]; | 89 | agent_data.lastname = (string)requestData["lastname"]; |
82 | agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); | 90 | agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); |
83 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | 91 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); |
84 | OpenSim_Main.gridServers.GridServer.agentcircuits.Add((uint)agent_data.circuitcode,agent_data); | 92 | if (OpenSim_Main.gridServers.GridServer.GetName() == "Remote") |
93 | { | ||
94 | ((RemoteGridBase) OpenSim_Main.gridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode,agent_data); | ||
95 | } | ||
85 | return "<?xml version=\"1.0\"?><methodResponse><params /></methodResponse>"; | 96 | return "<?xml version=\"1.0\"?><methodResponse><params /></methodResponse>"; |
86 | break; | 97 | break; |
87 | } | 98 | } |
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 | |||
46 | 46 | ||
47 | public interface IGridServer | 47 | public interface IGridServer |
48 | { | 48 | { |
49 | bool RequestConnection(); | ||
50 | Dictionary<uint, agentcircuitdata> agentcircuits { | ||
51 | get; | ||
52 | set; | ||
53 | } | ||
54 | UUIDBlock RequestUUIDBlock(); | 49 | UUIDBlock RequestUUIDBlock(); |
55 | void RequestNeighbours(); //should return a array of neighbouring regions | 50 | void RequestNeighbours(); //should return a array of neighbouring regions |
56 | AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); | 51 | AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); |
57 | bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); | 52 | bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); |
53 | string GetName(); | ||
54 | bool RequestConnection(); | ||
58 | void SetServerInfo(string ServerUrl, string ServerKey); | 55 | void SetServerInfo(string ServerUrl, string ServerKey); |
59 | void AddNewSession(Login session); // only used by local version of grid server | 56 | } |
60 | // and didn't use to be part of this interface until we put this in a dll | 57 | |
58 | public abstract class RemoteGridBase : IGridServer | ||
59 | { | ||
60 | public abstract Dictionary<uint, agentcircuitdata> agentcircuits { | ||
61 | get; | ||
62 | set; | ||
63 | } | ||
64 | |||
65 | public abstract UUIDBlock RequestUUIDBlock(); | ||
66 | public abstract void RequestNeighbours(); | ||
67 | public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); | ||
68 | public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); | ||
69 | public abstract string GetName(); | ||
70 | public abstract bool RequestConnection(); | ||
71 | public abstract void SetServerInfo(string ServerUrl, string ServerKey); | ||
72 | } | ||
73 | |||
74 | public abstract class LocalGridBase : IGridServer | ||
75 | { | ||
76 | public abstract UUIDBlock RequestUUIDBlock(); | ||
77 | public abstract void RequestNeighbours(); | ||
78 | public abstract AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); | ||
79 | public abstract bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode); | ||
80 | public abstract string GetName(); | ||
81 | public abstract bool RequestConnection(); | ||
82 | public abstract void SetServerInfo(string ServerUrl, string ServerKey); | ||
83 | public abstract void AddNewSession(Login session); | ||
61 | } | 84 | } |
62 | 85 | ||
63 | public struct UUIDBlock | 86 | 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 | |||
249 | _login.BaseFolder = BaseFolderID; | 249 | _login.BaseFolder = BaseFolderID; |
250 | _login.InventoryFolder = InventoryFolderID; | 250 | _login.InventoryFolder = InventoryFolderID; |
251 | 251 | ||
252 | //working on local computer so lets add to the gridserver's list of sessions | 252 | //working on local computer so lets add to the gridserver's list of sessions? |
253 | this._gridServer.AddNewSession(_login); | 253 | if(OpenSim_Main.gridServers.GridServer.GetName() == "Local") |
254 | { | ||
255 | ((LocalGridBase)this._gridServer).AddNewSession(_login); | ||
256 | } | ||
254 | 257 | ||
255 | // forward the XML-RPC response to the client | 258 | // forward the XML-RPC response to the client |
256 | writer.WriteLine("HTTP/1.0 200 OK"); | 259 | 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 | |||
110 | } | 110 | } |
111 | } | 111 | } |
112 | 112 | ||
113 | public class LocalGridServer :IGridServer | 113 | public class LocalGridServer : LocalGridBase |
114 | { | 114 | { |
115 | public List<Login> Sessions = new List<Login>(); | 115 | public List<Login> Sessions = new List<Login>(); |
116 | 116 | ||
117 | private Dictionary<uint, agentcircuitdata> AgentCircuits = new Dictionary<uint, agentcircuitdata>(); | ||
118 | |||
119 | public Dictionary<uint, agentcircuitdata> agentcircuits { | ||
120 | get {return agentcircuits;} | ||
121 | set {agentcircuits=value;} | ||
122 | } | ||
123 | |||
124 | public LocalGridServer() | 117 | public LocalGridServer() |
125 | { | 118 | { |
126 | Sessions = new List<Login>(); | 119 | Sessions = new List<Login>(); |
127 | ServerConsole.MainConsole.Instance.WriteLine("Local Grid Server class created"); | 120 | ServerConsole.MainConsole.Instance.WriteLine("Local Grid Server class created"); |
128 | } | 121 | } |
129 | 122 | ||
130 | public bool RequestConnection() | 123 | public override string GetName() |
124 | { | ||
125 | return "Local"; | ||
126 | } | ||
127 | |||
128 | public override bool RequestConnection() | ||
131 | { | 129 | { |
132 | return true; | 130 | return true; |
133 | } | 131 | } |
134 | public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | 132 | public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) |
135 | { | 133 | { |
136 | //we are running local | 134 | //we are running local |
137 | AuthenticateResponse user = new AuthenticateResponse(); | 135 | AuthenticateResponse user = new AuthenticateResponse(); |
@@ -151,31 +149,32 @@ namespace LocalGridServers | |||
151 | return(user); | 149 | return(user); |
152 | } | 150 | } |
153 | 151 | ||
154 | public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | 152 | public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) |
155 | { | 153 | { |
156 | return(true); | 154 | return(true); |
157 | } | 155 | } |
158 | 156 | ||
159 | public UUIDBlock RequestUUIDBlock() | 157 | public override UUIDBlock RequestUUIDBlock() |
160 | { | 158 | { |
161 | UUIDBlock uuidBlock = new UUIDBlock(); | 159 | UUIDBlock uuidBlock = new UUIDBlock(); |
162 | return(uuidBlock); | 160 | return(uuidBlock); |
163 | } | 161 | } |
164 | 162 | ||
165 | public void RequestNeighbours() | 163 | public override void RequestNeighbours() |
166 | { | 164 | { |
167 | return; | 165 | return; |
168 | } | 166 | } |
169 | 167 | ||
170 | public void SetServerInfo(string ServerUrl, string ServerKey) | 168 | public override void SetServerInfo(string ServerUrl, string ServerKey) |
171 | { | 169 | { |
172 | 170 | ||
173 | } | 171 | } |
172 | |||
174 | /// <summary> | 173 | /// <summary> |
175 | /// used by the local login server to inform us of new sessions | 174 | /// used by the local login server to inform us of new sessions |
176 | /// </summary> | 175 | /// </summary> |
177 | /// <param name="session"></param> | 176 | /// <param name="session"></param> |
178 | public void AddNewSession(Login session) | 177 | public override void AddNewSession(Login session) |
179 | { | 178 | { |
180 | lock(this.Sessions) | 179 | lock(this.Sessions) |
181 | { | 180 | { |
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 | |||
65 | return(new RemoteAssetServer()); | 65 | return(new RemoteAssetServer()); |
66 | } | 66 | } |
67 | } | 67 | } |
68 | public class RemoteGridServer :IGridServer | 68 | public class RemoteGridServer : RemoteGridBase |
69 | { | 69 | { |
70 | private string GridServerUrl; | 70 | private string GridServerUrl; |
71 | private string GridSendKey; | 71 | private string GridSendKey; |
72 | private Dictionary<uint, agentcircuitdata> AgentCircuits = new Dictionary<uint, agentcircuitdata>(); | 72 | private Dictionary<uint, agentcircuitdata> AgentCircuits = new Dictionary<uint, agentcircuitdata>(); |
73 | 73 | ||
74 | public Dictionary<uint, agentcircuitdata> agentcircuits { | 74 | public override Dictionary<uint, agentcircuitdata> agentcircuits { |
75 | get {return AgentCircuits;} | 75 | get {return AgentCircuits;} |
76 | set {AgentCircuits=value;} | 76 | set {AgentCircuits=value;} |
77 | } | 77 | } |
@@ -81,13 +81,12 @@ namespace RemoteGridServers | |||
81 | ServerConsole.MainConsole.Instance.WriteLine("Remote Grid Server class created"); | 81 | ServerConsole.MainConsole.Instance.WriteLine("Remote Grid Server class created"); |
82 | } | 82 | } |
83 | 83 | ||
84 | public bool RequestConnection() | 84 | public override bool RequestConnection() |
85 | { | 85 | { |
86 | return true; | 86 | return true; |
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | public override AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode) | |
90 | public AuthenticateResponse AuthenticateSession(LLUUID sessionID, LLUUID agentID, uint circuitcode) | ||
91 | { | 90 | { |
92 | agentcircuitdata validcircuit=this.AgentCircuits[circuitcode]; | 91 | agentcircuitdata validcircuit=this.AgentCircuits[circuitcode]; |
93 | AuthenticateResponse user = new AuthenticateResponse(); | 92 | AuthenticateResponse user = new AuthenticateResponse(); |
@@ -110,7 +109,7 @@ namespace RemoteGridServers | |||
110 | return(user); | 109 | return(user); |
111 | } | 110 | } |
112 | 111 | ||
113 | public bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) | 112 | public override bool LogoutSession(LLUUID sessionID, LLUUID agentID, uint circuitCode) |
114 | { | 113 | { |
115 | WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString()); | 114 | WebRequest DeleteSession = WebRequest.Create(GridServerUrl + "/usersessions/" + sessionID.ToString()); |
116 | DeleteSession.Method="DELETE"; | 115 | DeleteSession.Method="DELETE"; |
@@ -127,26 +126,26 @@ namespace RemoteGridServers | |||
127 | return(true); | 126 | return(true); |
128 | } | 127 | } |
129 | 128 | ||
130 | public UUIDBlock RequestUUIDBlock() | 129 | public override UUIDBlock RequestUUIDBlock() |
131 | { | 130 | { |
132 | UUIDBlock uuidBlock = new UUIDBlock(); | 131 | UUIDBlock uuidBlock = new UUIDBlock(); |
133 | return(uuidBlock); | 132 | return(uuidBlock); |
134 | } | 133 | } |
135 | 134 | ||
136 | public void RequestNeighbours() | 135 | public override void RequestNeighbours() |
137 | { | 136 | { |
138 | return; | 137 | return; |
139 | } | 138 | } |
140 | 139 | ||
141 | public void SetServerInfo(string ServerUrl, string ServerKey) | 140 | public override void SetServerInfo(string ServerUrl, string ServerKey) |
142 | { | 141 | { |
143 | this.GridServerUrl = ServerUrl; | 142 | this.GridServerUrl = ServerUrl; |
144 | this.GridSendKey = ServerKey; | 143 | this.GridSendKey = ServerKey; |
145 | } | 144 | } |
146 | 145 | ||
147 | public void AddNewSession(Login session) | 146 | public override string GetName() |
148 | { | 147 | { |
149 | 148 | return "Remote"; | |
150 | } | 149 | } |
151 | } | 150 | } |
152 | 151 | ||