mirror of
https://github.com/rilaxik/fivem-rpc.git
synced 2026-09-28 01:29:13 +00:00
chore(rpc): add explanation comments
This commit is contained in:
@@ -164,6 +164,8 @@ export class RPCInstanceWebview extends RPCInstanceBase {
|
|||||||
},
|
},
|
||||||
body: stringify(data),
|
body: stringify(data),
|
||||||
}
|
}
|
||||||
|
// FiveM injects GetParentResourceName into NUI pages. Without it (page
|
||||||
|
// opened in a regular browser) the fetch fails and the call rejects.
|
||||||
const resourceName = window?.GetParentResourceName?.() ?? 'nui-frame-app'
|
const resourceName = window?.GetParentResourceName?.() ?? 'nui-frame-app'
|
||||||
return fetch(
|
return fetch(
|
||||||
`https://${resourceName}/${RPCEvents.LISTENER_WEB}`,
|
`https://${resourceName}/${RPCEvents.LISTENER_WEB}`,
|
||||||
|
|||||||
@@ -64,7 +64,14 @@ export function stringifyWeb(data: RPCStateWeb): RPCStateWebRaw {
|
|||||||
return JSON.stringify(data) as RPCStateWebRaw
|
return JSON.stringify(data) as RPCStateWebRaw
|
||||||
}
|
}
|
||||||
|
|
||||||
/** **Internal** */
|
/**
|
||||||
|
* **Internal**
|
||||||
|
*
|
||||||
|
* UUID v4 shaped call id. Not `crypto.randomUUID`: the FiveM client runtime
|
||||||
|
* has no `crypto` global, and one generator serves all environments. Only
|
||||||
|
* pairs a response with its call, so it need not be unguessable: the server
|
||||||
|
* binds each call to its target player (`Pending` peer check).
|
||||||
|
*/
|
||||||
export function generateUUID(): string {
|
export function generateUUID(): string {
|
||||||
let uuid = ''
|
let uuid = ''
|
||||||
let random = 0
|
let random = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user