diff options
| author | Patrick Kubiak <epicpatka@gmail.com> | 2022-05-10 10:13:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-10 17:13:53 +0300 |
| commit | 945db5de4788feefebc845817752472419051640 (patch) | |
| tree | 5ab4864a6abed7fd5b107b8c91016834fcd1bd84 | |
| parent | 28746e3962e2d816c2ad810fbf74795ae5dd94ed (diff) | |
| download | decky-loader-945db5de4788feefebc845817752472419051640.tar.gz decky-loader-945db5de4788feefebc845817752472419051640.zip | |
Use unique ids in call_server_method (#55)
| -rw-r--r-- | plugin_loader/static/library.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/plugin_loader/static/library.js b/plugin_loader/static/library.js index abd4453f..744cc77f 100644 --- a/plugin_loader/static/library.js +++ b/plugin_loader/static/library.js @@ -8,7 +8,7 @@ window.addEventListener("message", function(evt) { }, false); async function call_server_method(method_name, arg_object={}) { - let id = `${new Date().getTime()}`; + let id = `${uuidv4()}`; console.debug(JSON.stringify({ "id": id, "method": method_name, @@ -22,6 +22,13 @@ async function call_server_method(method_name, arg_object={}) { }); } +// Source: https://stackoverflow.com/a/2117523 Thanks! +function uuidv4() { + return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => + (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) + ); +} + async function fetch_nocors(url, request={}) { let args = { method: "POST", headers: {}, body: "" }; request = {...args, ...request}; |
