aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorteravus2013-02-05 18:02:25 -0500
committerteravus2013-02-05 18:02:25 -0500
commit1dc09d8e8f4a6caa321d0227722af97ee4aeed6a (patch)
tree88bf751c1031c8a458e57c79c37804f983b43e42 /OpenSim
parentMerge branch 'master' into JSONTCPClient (diff)
downloadopensim-SC-1dc09d8e8f4a6caa321d0227722af97ee4aeed6a.zip
opensim-SC-1dc09d8e8f4a6caa321d0227722af97ee4aeed6a.tar.gz
opensim-SC-1dc09d8e8f4a6caa321d0227722af97ee4aeed6a.tar.bz2
opensim-SC-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 '')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs38
-rw-r--r--OpenSim/Framework/Servers/Tests/OSHttpTests.cs5
-rw-r--r--OpenSim/Region/ClientStack/TCPJSONStream/OpenSimWebSocketBase.cs6
3 files changed, 45 insertions, 4 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;
diff --git a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
index 3412e0f..5b912b4 100644
--- a/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
+++ b/OpenSim/Framework/Servers/Tests/OSHttpTests.cs
@@ -70,6 +70,11 @@ namespace OpenSim.Framework.Servers.Tests
70 public void Close() { } 70 public void Close() { }
71 public bool EndWhenDone { get { return false;} set { return;}} 71 public bool EndWhenDone { get { return false;} set { return;}}
72 72
73 public HTTPNetworkContext GiveMeTheNetworkStreamIKnowWhatImDoing()
74 {
75 return new HTTPNetworkContext();
76 }
77
73 public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { }; 78 public event EventHandler<DisconnectedEventArgs> Disconnected = delegate { };
74 /// <summary> 79 /// <summary>
75 /// A request have been received in the context. 80 /// A request have been received in the context.
diff --git a/OpenSim/Region/ClientStack/TCPJSONStream/OpenSimWebSocketBase.cs b/OpenSim/Region/ClientStack/TCPJSONStream/OpenSimWebSocketBase.cs
index 379438d..6d02543 100644
--- a/OpenSim/Region/ClientStack/TCPJSONStream/OpenSimWebSocketBase.cs
+++ b/OpenSim/Region/ClientStack/TCPJSONStream/OpenSimWebSocketBase.cs
@@ -47,7 +47,7 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream
47 47
48 public void NetworkStop() 48 public void NetworkStop()
49 { 49 {
50 m_tcpServer.Stop(); 50 // m_tcpServer.Stop();
51 } 51 }
52 52
53 public bool HandlesRegion(Location x) 53 public bool HandlesRegion(Location x)
@@ -62,12 +62,12 @@ namespace OpenSim.Region.ClientStack.TCPJSONStream
62 62
63 public void Start() 63 public void Start()
64 { 64 {
65 m_tcpServer.Start(); 65 //m_tcpServer.Start();
66 } 66 }
67 67
68 public void Stop() 68 public void Stop()
69 { 69 {
70 m_tcpServer.Stop(); 70 // m_tcpServer.Stop();
71 } 71 }
72 } 72 }
73} \ No newline at end of file 73} \ No newline at end of file