File tree Expand file tree Collapse file tree
test-app/app/src/main/java/com/tns Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -231,9 +231,22 @@ protected Response serveHttp(IHTTPSession session) {
231231 return super .serveHttp (session );
232232 }
233233
234+ private JsV8InspectorWebSocket webSocket ;
235+
234236 @ Override
235237 protected WebSocket openWebSocket (IHTTPSession handshake ) {
236- return new JsV8InspectorWebSocket (handshake , currentRuntimeLogger );
238+ // close the previous webSocket
239+ if (this .webSocket != null ) {
240+ try {
241+ this .webSocket .close (WebSocketFrame .CloseCode .NormalClosure , "New browser connection is open" , false );
242+ } catch (IOException ioException ) {
243+ if (this .webSocket .getState () != State .CLOSED ) {
244+ Log .e ("{N}.v8-inspector" , "Error closing previous connection" , ioException );
245+ }
246+ }
247+ }
248+ this .webSocket = new JsV8InspectorWebSocket (handshake );
249+ return this .webSocket ;
237250 }
238251 }
239252
You can’t perform that action at this time.
0 commit comments