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.

user_profiles
teravus 2013-02-05 18:02:25 -05:00
parent ee4f8ac193
commit 1dc09d8e8f
6 changed files with 4543 additions and 4502 deletions

View File

@ -54,6 +54,8 @@ namespace OpenSim.Framework.Servers.HttpServer
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private HttpServerLogWriter httpserverlog = new HttpServerLogWriter(); private HttpServerLogWriter httpserverlog = new HttpServerLogWriter();
public delegate void WebSocketRequestDelegate(string servicepath, WebSocketHTTPServerHandler handler);
/// <summary> /// <summary>
/// Gets or sets the debug level. /// Gets or sets the debug level.
/// </summary> /// </summary>
@ -87,6 +89,9 @@ namespace OpenSim.Framework.Servers.HttpServer
protected Dictionary<string, PollServiceEventArgs> m_pollHandlers = protected Dictionary<string, PollServiceEventArgs> m_pollHandlers =
new Dictionary<string, PollServiceEventArgs>(); new Dictionary<string, PollServiceEventArgs>();
protected Dictionary<string, WebSocketRequestDelegate> m_WebSocketHandlers =
new Dictionary<string, WebSocketRequestDelegate>();
protected uint m_port; protected uint m_port;
protected uint m_sslport; protected uint m_sslport;
protected bool m_ssl; 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() public List<string> GetStreamHandlerKeys()
{ {
lock (m_streamHandlers) lock (m_streamHandlers)
@ -409,9 +430,24 @@ namespace OpenSim.Framework.Servers.HttpServer
public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request) public void OnHandleRequestIOThread(IHttpClientContext context, IHttpRequest request)
{ {
OSHttpRequest req = new OSHttpRequest(context, 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); OSHttpResponse resp = new OSHttpResponse(new HttpResponse(context, request),context);
HandleRequest(req, resp); HandleRequest(req, resp);
// !!!HACK ALERT!!! // !!!HACK ALERT!!!
// There seems to be a bug in the underlying http code that makes subsequent requests // 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); LogIncomingToStreamHandler(request, requestHandler);
response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type. response.ContentType = requestHandler.ContentType; // Lets do this defaulting before in case handler has varying content type.
if (requestHandler is IStreamedRequestHandler) if (requestHandler is IStreamedRequestHandler)
{ {
IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler; IStreamedRequestHandler streamedRequestHandler = requestHandler as IStreamedRequestHandler;

View File

@ -70,6 +70,11 @@ namespace OpenSim.Framework.Servers.Tests
public void Close() { } public void Close() { }
public bool EndWhenDone { get { return false;} set { return;}} public bool EndWhenDone { get { return false;} set { return;}}
public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing()
{
return new HTTPNetworkContext();
}
public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { }; public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { };
/// <summary> /// <summary>
/// A request have been received in the context. /// A request have been received in the context.

View File

@ -47,7 +47,7 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream
public void NetworkStop() public void NetworkStop()
{ {
m_tcpServer.Stop(); // m_tcpServer.Stop();
} }
public bool HandlesRegion(Location x) public bool HandlesRegion(Location x)
@ -62,12 +62,12 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream
public void Start() public void Start()
{ {
m_tcpServer.Start(); //m_tcpServer.Start();
} }
public void Stop() 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