mirror of
https://github.com/hansjone/netx.git
synced 2026-10-09 11:50:44 +08:00
Close only this WebCRT window's sessions on leave; require manual reconnect.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
938cd39c06
commit
4ea3b737f2
2 changed files with 77 additions and 118 deletions
|
|
@ -665,6 +665,21 @@ export const closeWebcrtSession = (sessionId: string) =>
|
|||
`/v1/webcrt/sessions/${encodeURIComponent(sessionId)}`,
|
||||
);
|
||||
|
||||
/** Best-effort close during tab/window unload (fetch keepalive survives navigation). */
|
||||
export function closeWebcrtSessionsKeepalive(sessionIds: string[]): void {
|
||||
const ids = [...new Set(sessionIds.map((id) => String(id || "").trim()).filter(Boolean))];
|
||||
if (!ids.length) return;
|
||||
const headers = authHeaders();
|
||||
for (const id of ids) {
|
||||
const path = `/v1/webcrt/sessions/${encodeURIComponent(id)}`;
|
||||
try {
|
||||
void fetch(path, { method: "DELETE", headers, keepalive: true });
|
||||
} catch {
|
||||
/* ignore unload failures */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type WebcrtSftpItem = {
|
||||
name: string;
|
||||
size: number;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue