Skip to content

Commit

Permalink
fix(ui): Socket Panel > isClientConnected was returning true even if …
Browse files Browse the repository at this point in the history
…socket was disconnected in reality - so now we use the actual state of the socket instead of always returning true
  • Loading branch information
flawiddsouza committed Jan 19, 2024
1 parent 8f7cf46 commit 4ab5bc4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/ui/src/components/SocketPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ function clearMessages(client: Client) {
function disconnect(client: Client) {
const socket = sockets[activeTab.value._id + '-' + client.id]
if(socket === undefined || socket === null) {
return false
}
if(socket instanceof WebSocket) {
socket.close()
}
Expand Down Expand Up @@ -637,11 +641,11 @@ function isClientConnected(client: Client) {
}
if(socket instanceof WebSocket) {
return true
return socket.readyState === WebSocket.OPEN
}
if(socket.constructor.name.startsWith('Socket')) {
return true
return socket.connected
}
return false
Expand Down

0 comments on commit 4ab5bc4

Please sign in to comment.