From 1dc09d8e8f4a6caa321d0227722af97ee4aeed6a Mon Sep 17 00:00:00 2001
From: teravus
Date: Tue, 5 Feb 2013 18:02:25 -0500
Subject: 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.
---
.../Framework/Servers/HttpServer/BaseHttpServer.cs | 38 +++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
(limited to 'OpenSim/Framework/Servers/HttpServer')
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
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
+ public delegate void WebSocketRequestDelegate(string servicepath, WebSocketHTTPServerHandler handler);
+
///
/// Gets or sets the debug level.
///
@@ -87,6 +89,9 @@ namespace OpenSim.Framework.Servers.HttpServer
protected Dictionary m_pollHandlers =
new Dictionary();
+ protected Dictionary m_WebSocketHandlers =
+ new Dictionary();
+
protected uint m_port;
protected uint m_sslport;
protected bool m_ssl;
@@ -170,6 +175,22 @@ namespace OpenSim.Framework.Servers.HttpServer
}
}
+ public void AddWebSocketHandler(string servicepath, WebSocketRequestDelegate handler)
+ {
+ lock (m_WebSocketHandlers)
+ {
+ if (!m_WebSocketHandlers.ContainsKey(servicepath))
+ m_WebSocketHandlers.Add(servicepath, handler);
+ }
+ }
+
+ public void RemoveWebSocketHandler(string servicepath)
+ {
+ lock (m_WebSocketHandlers)
+ if (m_WebSocketHandlers.ContainsKey(servicepath))
+ m_WebSocketHandlers.Remove(servicepath);
+ }
+
public List GetStreamHandlerKeys()
{
lock (m_streamHandlers)
@@ -409,9 +430,24 @@ namespace OpenSim.Framework.Servers.HttpServer
public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
{
+
OSHttpRequest req = new OSHttpRequest(context, request);
+ WebSocketRequestDelegate dWebSocketRequestDelegate = null;
+ lock (m_WebSocketHandlers)
+ {
+ if (m_WebSocketHandlers.ContainsKey(req.RawUrl))
+ dWebSocketRequestDelegate = m_WebSocketHandlers[req.RawUrl];
+ }
+ if (dWebSocketRequestDelegate != null)
+ {
+ dWebSocketRequestDelegate(req.Url.AbsolutePath, new WebSocketHTTPServerHandler(req, context, 16384));
+ return;
+ }
+
OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
+
HandleRequest(req, resp);
+
// !!!HACK ALERT!!!
// There seems to be a bug in the underlying http code that makes subsequent requests
@@ -500,7 +536,7 @@ namespace OpenSim.Framework.Servers.HttpServer
LogIncomingToStreamHandler(request, requestHandler);
response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
-
+
if (requestHandler is IStreamedRequestHandler)
{
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;
--
cgit v1.1