Skip to content

Commit

Permalink
Disconnecting the debugger (#534)
Browse files Browse the repository at this point in the history
* Added 'close connection' button to close the connection to the specific websocket
* Decline any current Log when clicking the 'close connection' button

Co-authored-by: Andrea Jiang <jianga@ethz.ch>
  • Loading branch information
andreaj00 and andreaj00 authored Feb 16, 2024
1 parent fab12b4 commit 2e972b8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions frontend/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ button {
overflow: auto;
}

/* Close connection button*/
.close-button {
background-color: #c0392b; /* Red color */
color: #fff; /* White text color */
border: none;
padding: 8px 12px;
font-size: 14px;
cursor: pointer;
border-radius: 4px;
float: right; /* Float the button to the right */
margin: 5px;
}

/* EditableText*/
/* Style for spans with text content */
.editable-text-span {
Expand Down
17 changes: 17 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,25 @@
}
};

const closeConnection = () => {
console.log('Closing connection from button');
if (ws) {
declineIncomingLog();
ws.close();

// Send the response on the WebSocket
let webSocketResponse = {
"Type": "close",
"Value": ""
};
const webSocketResponseJSON = JSON.stringify(webSocketResponse);
ws.send(webSocketResponseJSON);
}
}

return (
<div id="sub-screen" className="sub-screen">
<button onClick={closeConnection} className="close-button">Close Connection</button>
<p className="websocket-console-title">
WebSocket Console for Port {port}:
</p>
Expand Down

0 comments on commit 2e972b8

Please sign in to comment.