mirror of
https://github.com/block/buzz.git
synced 2026-10-31 06:21:34 +00:00
Signed-off-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1mprnacetjua2xx3p5eddmhxyk6wv929ymm5py8kd2xfxurxahspqqlgyta <d8473ee32b973aa31a21a65adddcc4b69cc2a8a4dee8121ecd51926e0cddbc02@sprout-oss.stage.blox.sqprod.co>
31 lines
840 B
TypeScript
31 lines
840 B
TypeScript
import { invoke } from "@tauri-apps/api/core";
|
|
|
|
/**
|
|
* Remove the connection from the native manager before waiting for its socket
|
|
* task to stop. The command is bounded and idempotent; failures mean the
|
|
* process is already tearing down or the socket is already gone.
|
|
*/
|
|
export function closeWebSocket(
|
|
id: number,
|
|
reason: string,
|
|
invokeFn: typeof invoke = invoke,
|
|
): Promise<void> {
|
|
return invokeFn("plugin:websocket|disconnect", { id }).then(
|
|
() => undefined,
|
|
(err) => {
|
|
console.debug(`closeWebSocket(${id}, ${reason}) rejected:`, err);
|
|
},
|
|
);
|
|
}
|
|
|
|
export function closeAllWebSockets(
|
|
invokeFn: typeof invoke = invoke,
|
|
): Promise<void> {
|
|
return invokeFn("plugin:websocket|disconnect_all").then(
|
|
() => undefined,
|
|
(err) => {
|
|
console.debug("closeAllWebSockets() rejected:", err);
|
|
},
|
|
);
|
|
}
|