aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Servers/HttpServer
diff options
context:
space:
mode:
authorteravus2013-02-05 18:02:25 -0500
committerteravus2013-02-05 18:02:25 -0500
commit1dc09d8e8f4a6caa321d0227722af97ee4aeed6a (patch)
tree88bf751c1031c8a458e57c79c37804f983b43e42 /OpenSim/Framework/Servers/HttpServer
parentMerge branch 'master' into JSONTCPClient (diff)
downloadopensim-SC_OLD-1dc09d8e8f4a6caa321d0227722af97ee4aeed6a.zip
opensim-SC_OLD-1dc09d8e8f4a6caa321d0227722af97ee4aeed6a.tar.gz
opensim-SC_OLD-1dc09d8e8f4a6caa321d0227722af97ee4aeed6a.tar.bz2
opensim-SC_OLD-1dc09d8e8f4a6caa321d0227722af97ee4aeed6a.tar.xz
We're not really done here.. but we're getting there. Socket Read is working.. Still have to do Header.ToBytes and compose a websocket frame with a payload.
Diffstat (limited to 'OpenSim/Framework/Servers/HttpServer')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs38
1 files changed, 37 insertions, 1 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index b24336d..dcfe99a 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -54,6 +54,8 @@ namespace OpenSim.Framework.Servers.HttpServer
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); 55 private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
56 56
57 public delegate void WebSocketRequestDelegate(string servicepath, WebSocketHTTPServerHandler handler);
58
57 /// <summary> 59 /// <summary>
58 /// Gets or sets the debug level. 60 /// Gets or sets the debug level.
59 /// </summary> 61 /// </summary>
@@ -87,6 +89,9 @@ namespace OpenSim.Framework.Servers.HttpServer
87 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = 89 protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
88 new Dictionary<string, PollServiceEventArgs>(); 90 new Dictionary<string, PollServiceEventArgs>();
89 91
92 protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers =
93 new Dictionary<string, WebSocketRequestDelegate>();
94
90 protected uint m_port; 95 protected uint m_port;
91 protected uint m_sslport; 96 protected uint m_sslport;
92 protected bool m_ssl; 97 protected bool m_ssl;
@@ -170,6 +175,22 @@ namespace OpenSim.Framework.Servers.HttpServer
170 } 175 }
171 } 176 }
172 177
178 public void AddWebSocketHandler(string servicepath, WebSocketRequestDelegate handler)
179 {
180 lock (m_WebSocketHandlers)
181 {
182 if (!m_WebSocketHandlers.ContainsKey(servicepath))
183 m_WebSocketHandlers.Add(servicepath, handler);
184 }
185 }
186
187 public void RemoveWebSocketHandler(string servicepath)
188 {
189 lock (m_WebSocketHandlers)
190 if (m_WebSocketHandlers.ContainsKey(servicepath))
191 m_WebSocketHandlers.Remove(servicepath);
192 }
193
173 public List<string> GetStreamHandlerKeys() 194 public List<string> GetStreamHandlerKeys()
174 { 195 {
175 lock (m_streamHandlers) 196 lock (m_streamHandlers)
@@ -409,9 +430,24 @@ namespace OpenSim.Framework.Servers.HttpServer
409 430
410 public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) 431 public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
411 { 432 {
433
412 OSHttpRequest req = new OSHttpRequest(context, request); 434 OSHttpRequest req = new OSHttpRequest(context, request);
435 WebSocketRequestDelegate dWebSocketRequestDelegate = null;
436 lock (m_WebSocketHandlers)
437 {
438 if (m_WebSocketHandlers.ContainsKey(req.RawUrl))
439 dWebSocketRequestDelegate = m_WebSocketHandlers[req.RawUrl];
440 }
441 if (dWebSocketRequestDelegate != null)
442 {
443 dWebSocketRequestDelegate(req.Url.AbsolutePath, new WebSocketHTTPServerHandler(req, context, 16384));
444 return;
445 }
446
413 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context); 447 OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
448
414 HandleRequest(req, resp); 449 HandleRequest(req, resp);
450
415 451
416 // !!!HACK ALERT!!! 452 // !!!HACK ALERT!!!
417 // There seems to be a bug in the underlying http code that makes subsequent requests 453 // There seems to be a bug in the underlying http code that makes subsequent requests
@@ -500,7 +536,7 @@ namespace OpenSim.Framework.Servers.HttpServer
500 LogIncomingToStreamHandler(request, requestHandler); 536 LogIncomingToStreamHandler(request, requestHandler);
501 537
502 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. 538 response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
503 539
504 if (requestHandler is IStreamedRequestHandler) 540 if (requestHandler is IStreamedRequestHandler)
505 { 541 {
506 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; 542 IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;