@@ -30,14 +30,14 @@ public class HttpListenerContext
3030 /// This stream is used for writing data.
3131 /// This stream owns the socket.
3232 /// </summary>
33- private OutputNetworkStreamWrapper m_clientOutputStream ;
33+ internal OutputNetworkStreamWrapper m_clientOutputStream ;
3434
3535 /// <summary>
3636 /// Member with network stream connected to client.
3737 /// This stream is used for Reading data.
3838 /// This stream does not own the socket.
3939 /// </summary>
40- private InputNetworkStreamWrapper m_clientInputStream ;
40+ internal InputNetworkStreamWrapper m_clientInputStream ;
4141
4242 /// <summary>
4343 /// Instance of the request from client.
@@ -50,7 +50,7 @@ public class HttpListenerContext
5050 /// Instance of the response to client.
5151 ///
5252 /// </summary>
53- private HttpListenerResponse m_ResponseToClient ;
53+ internal HttpListenerResponse m_ResponseToClient ;
5454
5555 /// <summary>
5656 /// Internal constructor, used each time client connects.
@@ -143,6 +143,25 @@ public void Close()
143143 Close ( - 2 ) ;
144144 }
145145
146+ /// <summary>
147+ /// Get WebsocketContext for WebsocketServer.
148+ /// This will release all bindings and resources from the HttpListner rendering HttpListnerContext unusable.
149+ /// </summary>
150+ internal WebSocketContext GetWebsocketContext ( )
151+ {
152+ var webSocketContext = new WebSocketContext ( m_clientOutputStream . m_Socket , m_clientOutputStream . m_Stream , Request . Headers ) ;
153+
154+ m_ResponseToClient . m_Listener . RemoveClientStream ( m_ResponseToClient . m_clientStream ) ;
155+
156+ m_ResponseToClient = null ;
157+ m_clientOutputStream = null ;
158+ m_clientInputStream = null ;
159+
160+
161+
162+ return webSocketContext ;
163+ }
164+
146165 /// <summary>
147166 /// Closes the stream attached to this listener context.
148167 /// </summary>
0 commit comments