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