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.
parent
ee4f8ac193
commit
1dc09d8e8f
|
@ -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;
|
||||
|
|
|
@ -70,6 +70,11 @@ namespace OpenSim.Framework.Servers.Tests
|
|||
public void Close() { }
|
||||
public bool EndWhenDone { get { return false;} set { return;}}
|
||||
|
||||
public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing()
|
||||
{
|
||||
return new HTTPNetworkContext();
|
||||
}
|
||||
|
||||
public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { };
|
||||
/// <summary>
|
||||
/// A request have been received in the context.
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream
|
|||
|
||||
public void NetworkStop()
|
||||
{
|
||||
m_tcpServer.Stop();
|
||||
// m_tcpServer.Stop();
|
||||
}
|
||||
|
||||
public bool HandlesRegion(Location x)
|
||||
|
@ -62,12 +62,12 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream
|
|||
|
||||
public void Start()
|
||||
{
|
||||
m_tcpServer.Start();
|
||||
//m_tcpServer.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
m_tcpServer.Stop();
|
||||
// m_tcpServer.Stop();
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue