Handle network connectivity changes in websocket (#30788)

This commit introduces listeners for network changes that will:
- Test the websocket if we get an offline event to check if we have disconnected.
- Re-connect the websocket immediately if we get an online event, and we are disconnected.

Additionally when a ping fails, we now immediately call the onclose() callback instead of waiting for the system to trigger it when the broken websocket closes. This allows us to re-connect much more quickly (since we don't have to wait for the broken websocket to get cleaned up by the system).
Этот коммит содержится в:
David Krauser
2025-05-09 15:39:10 -04:00
коммит произвёл GitHub
родитель 190b4e7f03
Коммит 67ab69606a
3 изменённых файлов: 353 добавлений и 65 удалений

Просмотреть файл

@@ -110,7 +110,6 @@ exports[`PostBodyAdditionalContent with a normal link Should render the plugin c
"conn": null,
"connectFailCount": 0,
"connectionId": "",
"connectionUrl": null,
"errorCallback": null,
"errorListeners": Set {},
"eventCallback": null,
@@ -119,6 +118,8 @@ exports[`PostBodyAdditionalContent with a normal link Should render the plugin c
"messageListeners": Set {},
"missedEventCallback": null,
"missedMessageListeners": Set {},
"offlineHandler": null,
"onlineHandler": null,
"pingInterval": null,
"postedAck": false,
"reconnectCallback": null,
@@ -128,6 +129,7 @@ exports[`PostBodyAdditionalContent with a normal link Should render the plugin c
"responseSequence": 1,
"serverHostname": "",
"serverSequence": 0,
"waitingForPong": false,
}
}
/>
@@ -168,7 +170,6 @@ exports[`PostBodyAdditionalContent with a normal link Should render the plugin c
"conn": null,
"connectFailCount": 0,
"connectionId": "",
"connectionUrl": null,
"errorCallback": null,
"errorListeners": Set {},
"eventCallback": null,
@@ -177,6 +178,8 @@ exports[`PostBodyAdditionalContent with a normal link Should render the plugin c
"messageListeners": Set {},
"missedEventCallback": null,
"missedMessageListeners": Set {},
"offlineHandler": null,
"onlineHandler": null,
"pingInterval": null,
"postedAck": false,
"reconnectCallback": null,
@@ -186,6 +189,7 @@ exports[`PostBodyAdditionalContent with a normal link Should render the plugin c
"responseSequence": 1,
"serverHostname": "",
"serverSequence": 0,
"waitingForPong": false,
}
}
/>