diff options
author | lbsa71 | 2007-03-27 20:45:04 +0000 |
---|---|---|
committer | lbsa71 | 2007-03-27 20:45:04 +0000 |
commit | 7adbe756fbb1d1c4cd71df90bd12d7e3da60bdf8 (patch) | |
tree | d8dc563b7fef4ce9dcc34fbcc31c3fcc7d99d49f /OpenSim.RegionServer/CAPS/SimHttp.cs | |
parent | * Config should be loaded before login server startup... (diff) | |
download | opensim-SC-7adbe756fbb1d1c4cd71df90bd12d7e3da60bdf8.zip opensim-SC-7adbe756fbb1d1c4cd71df90bd12d7e3da60bdf8.tar.gz opensim-SC-7adbe756fbb1d1c4cd71df90bd12d7e3da60bdf8.tar.bz2 opensim-SC-7adbe756fbb1d1c4cd71df90bd12d7e3da60bdf8.tar.xz |
* Reverting todays work. It was worth a try.
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/CAPS/SimHttp.cs | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/OpenSim.RegionServer/CAPS/SimHttp.cs b/OpenSim.RegionServer/CAPS/SimHttp.cs index 92bbc6f..a1073f0 100644 --- a/OpenSim.RegionServer/CAPS/SimHttp.cs +++ b/OpenSim.RegionServer/CAPS/SimHttp.cs | |||
@@ -39,27 +39,22 @@ using System.Collections.Generic; | |||
39 | using libsecondlife; | 39 | using libsecondlife; |
40 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
41 | using OpenSim.Framework.Interfaces; | 41 | using OpenSim.Framework.Interfaces; |
42 | using OpenSim.Servers; | ||
43 | 42 | ||
44 | namespace OpenSim.CAPS | 43 | namespace OpenSim.CAPS |
45 | { | 44 | { |
46 | // Dummy HTTP server, does nothing useful for now | 45 | // Dummy HTTP server, does nothing useful for now |
47 | 46 | ||
48 | public class SimCAPSHTTPServer : BaseHttpServer | 47 | public class SimCAPSHTTPServer |
49 | { | 48 | { |
50 | private Thread m_workerThread; | 49 | public Thread HTTPD; |
51 | private HttpListener m_httpListener; | 50 | public HttpListener Listener; |
52 | private Dictionary<string, IRestHandler> m_restHandlers = new Dictionary<string, IRestHandler>(); | 51 | private Dictionary<string, IRestHandler> restHandlers = new Dictionary<string, IRestHandler>(); |
53 | private IGridServer m_gridServer; | ||
54 | private int m_port; | ||
55 | 52 | ||
56 | public SimCAPSHTTPServer(IGridServer gridServer, int port) | 53 | public SimCAPSHTTPServer() |
57 | { | 54 | { |
58 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server"); | 55 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Starting up HTTP Server"); |
59 | m_workerThread = new Thread(new ThreadStart(StartHTTP)); | 56 | HTTPD = new Thread(new ThreadStart(StartHTTP)); |
60 | m_workerThread.Start(); | 57 | HTTPD.Start(); |
61 | m_gridServer = gridServer; | ||
62 | m_port = port; | ||
63 | } | 58 | } |
64 | 59 | ||
65 | public void StartHTTP() | 60 | public void StartHTTP() |
@@ -67,15 +62,15 @@ namespace OpenSim.CAPS | |||
67 | try | 62 | try |
68 | { | 63 | { |
69 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK"); | 64 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SimHttp.cs:StartHTTP() - Spawned main thread OK"); |
70 | m_httpListener = new HttpListener(); | 65 | Listener = new HttpListener(); |
71 | 66 | ||
72 | m_httpListener.Prefixes.Add("http://+:" + m_port + "/"); | 67 | Listener.Prefixes.Add("http://+:" + OpenSimRoot.Instance.Cfg.IPListenPort + "/"); |
73 | m_httpListener.Start(); | 68 | Listener.Start(); |
74 | 69 | ||
75 | HttpListenerContext context; | 70 | HttpListenerContext context; |
76 | while (true) | 71 | while (true) |
77 | { | 72 | { |
78 | context = m_httpListener.GetContext(); | 73 | context = Listener.GetContext(); |
79 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); | 74 | ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context); |
80 | } | 75 | } |
81 | } | 76 | } |
@@ -87,9 +82,9 @@ namespace OpenSim.CAPS | |||
87 | 82 | ||
88 | public bool AddRestHandler(string path, IRestHandler handler) | 83 | public bool AddRestHandler(string path, IRestHandler handler) |
89 | { | 84 | { |
90 | if (!this.m_restHandlers.ContainsKey(path)) | 85 | if (!this.restHandlers.ContainsKey(path)) |
91 | { | 86 | { |
92 | this.m_restHandlers.Add(path, handler); | 87 | this.restHandlers.Add(path, handler); |
93 | return true; | 88 | return true; |
94 | } | 89 | } |
95 | 90 | ||
@@ -113,12 +108,12 @@ namespace OpenSim.CAPS | |||
113 | agent_data.lastname = (string)requestData["lastname"]; | 108 | agent_data.lastname = (string)requestData["lastname"]; |
114 | agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); | 109 | agent_data.AgentID = new LLUUID((string)requestData["agent_id"]); |
115 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | 110 | agent_data.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); |
116 | if (m_gridServer.GetName() == "Remote") | 111 | if (OpenSimRoot.Instance.GridServers.GridServer.GetName() == "Remote") |
117 | { | 112 | { |
118 | 113 | ((RemoteGridBase)OpenSimRoot.Instance.GridServers.GridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); | |
119 | ((RemoteGridBase)m_gridServer).agentcircuits.Add((uint)agent_data.circuitcode, agent_data); | ||
120 | } | 114 | } |
121 | return "<?xml version=\"1.0\"?><methodResponse><params /></methodResponse>"; | 115 | return "<?xml version=\"1.0\"?><methodResponse><params /></methodResponse>"; |
116 | break; | ||
122 | } | 117 | } |
123 | } | 118 | } |
124 | catch (Exception e) | 119 | catch (Exception e) |
@@ -140,9 +135,9 @@ namespace OpenSim.CAPS | |||
140 | //path[0] should be empty so we are interested in path[1] | 135 | //path[0] should be empty so we are interested in path[1] |
141 | if (path.Length > 1) | 136 | if (path.Length > 1) |
142 | { | 137 | { |
143 | if ((path[1] != "") && (this.m_restHandlers.ContainsKey(path[1]))) | 138 | if ((path[1] != "") && (this.restHandlers.ContainsKey(path[1]))) |
144 | { | 139 | { |
145 | responseString = this.m_restHandlers[path[1]].HandleREST(requestBody, requestURL, requestMethod); | 140 | responseString = this.restHandlers[path[1]].HandleREST(requestBody, requestURL, requestMethod); |
146 | } | 141 | } |
147 | } | 142 | } |
148 | 143 | ||