mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the debug level.
|
||||
/// </summary>
|
||||
@@ -87,6 +89,9 @@ namespace OpenSim.Framework.Servers.HttpServer
|
||||
protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
|
||||
new Dictionary<string, PollServiceEventArgs>();
|
||||
|
||||
protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers =
|
||||
new Dictionary<string, WebSocketRequestDelegate>();
|
||||
|
||||
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<string> 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;
|
||||
|
||||
Reference in New Issue
Block a user