mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 02:09:24 +00:00
LibWeb: Close WebSockets when document is unloaded
Previously, they would stay open for the entire WebContent lifetime, or until the server closed the connection. This was particularly noticeable on collaborative websites/games such as https://jigsawpuzzles.io/, where the user using Ladybird would stick around even after they had navigated away.
This commit is contained in:
parent
3224f8acb5
commit
12a07b4fad
Notes:
github-actions[bot]
2025-02-26 10:48:29 +00:00
Author: https://github.com/Lubrsi
Commit: 12a07b4fad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3694
5 changed files with 66 additions and 3 deletions
|
@ -15,7 +15,6 @@
|
|||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
#include <LibWeb/DOM/EventTarget.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||
|
||||
#define ENUMERATE_WEBSOCKET_EVENT_HANDLERS(E) \
|
||||
|
@ -55,6 +54,8 @@ public:
|
|||
WebIDL::ExceptionOr<void> close(Optional<u16> code, Optional<String> reason);
|
||||
WebIDL::ExceptionOr<void> send(Variant<GC::Root<WebIDL::BufferSource>, GC::Root<FileAPI::Blob>, String> const& data);
|
||||
|
||||
void make_disappear();
|
||||
|
||||
private:
|
||||
void on_open();
|
||||
void on_message(ByteBuffer message, bool is_text);
|
||||
|
@ -72,6 +73,11 @@ private:
|
|||
URL::URL m_url;
|
||||
String m_binary_type { "blob"_string };
|
||||
RefPtr<Requests::WebSocket> m_websocket;
|
||||
|
||||
IntrusiveListNode<WebSocket> m_list_node;
|
||||
|
||||
public:
|
||||
using List = IntrusiveList<&WebSocket::m_list_node>;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue