- cef debug mode
This commit is contained in:
Danya H 2024-10-02 00:48:38 +01:00
parent ee4baca74a
commit cd142e4414

View File

@ -17,10 +17,20 @@ import {
} from './types' } from './types'
class Cef { class Cef {
private _debugMode: boolean = false
set debug(debug: boolean) {
this._debugMode = debug
}
public register<EventName extends keyof RageFW_ICustomCefEvent>( public register<EventName extends keyof RageFW_ICustomCefEvent>(
eventName: EventName, eventName: EventName,
callback: RageFW_CefCallback<EventName>, callback: RageFW_CefCallback<EventName>,
): void { ): void {
if (this._debugMode) {
console.log('[RPC](register):', eventName, callback)
}
if ('mp' in window) { if ('mp' in window) {
rpc.register(eventName, callback) rpc.register(eventName, callback)
} }
@ -32,6 +42,10 @@ class Cef {
? [RageFW_CefArgs<EventName>] ? [RageFW_CefArgs<EventName>]
: [] : []
): Promise<RageFW_CefReturn<EventName>> { ): Promise<RageFW_CefReturn<EventName>> {
if (this._debugMode) {
console.log('[RPC](trigger):', eventName, ...args)
}
if ('mp' in window) { if ('mp' in window) {
return rpc.call(eventName, args) return rpc.call(eventName, args)
} }
@ -47,6 +61,10 @@ class Cef {
? [RageFW_ServerArgs<EventName>] ? [RageFW_ServerArgs<EventName>]
: [] : []
): Promise<RageFW_ServerReturn<EventName>> { ): Promise<RageFW_ServerReturn<EventName>> {
if (this._debugMode) {
console.log('[RPC](triggerServer):', eventName, ...args)
}
if ('mp' in window) { if ('mp' in window) {
return rpc.callServer(eventName, args) return rpc.callServer(eventName, args)
} }
@ -62,6 +80,10 @@ class Cef {
? [RageFW_ClientArgs<EventName>] ? [RageFW_ClientArgs<EventName>]
: [] : []
): Promise<RageFW_ClientReturn<EventName>> { ): Promise<RageFW_ClientReturn<EventName>> {
if (this._debugMode) {
console.log('[RPC](triggerClient):', eventName, ...args)
}
if ('mp' in window) { if ('mp' in window) {
return rpc.callClient(eventName, args) return rpc.callClient(eventName, args)
} }