mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-07-11 17:12:01 +00:00
Use unique ids in call_server_method (#55)
This commit is contained in:
@@ -8,7 +8,7 @@ window.addEventListener("message", function(evt) {
|
|||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
async function call_server_method(method_name, arg_object={}) {
|
async function call_server_method(method_name, arg_object={}) {
|
||||||
let id = `${new Date().getTime()}`;
|
let id = `${uuidv4()}`;
|
||||||
console.debug(JSON.stringify({
|
console.debug(JSON.stringify({
|
||||||
"id": id,
|
"id": id,
|
||||||
"method": method_name,
|
"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={}) {
|
async function fetch_nocors(url, request={}) {
|
||||||
let args = { method: "POST", headers: {}, body: "" };
|
let args = { method: "POST", headers: {}, body: "" };
|
||||||
request = {...args, ...request};
|
request = {...args, ...request};
|
||||||
|
|||||||
Reference in New Issue
Block a user