Release v.0.1.0 #2
@ -21,8 +21,10 @@ class Cef {
|
|||||||
eventName: EventName,
|
eventName: EventName,
|
||||||
callback: RageFW_CefCallback<EventName>,
|
callback: RageFW_CefCallback<EventName>,
|
||||||
): void {
|
): void {
|
||||||
|
if ('mp' in window) {
|
||||||
rpc.register(eventName, callback)
|
rpc.register(eventName, callback)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public trigger<EventName extends keyof RageFW_ICustomCefEvent>(
|
public trigger<EventName extends keyof RageFW_ICustomCefEvent>(
|
||||||
eventName: EventName,
|
eventName: EventName,
|
||||||
@ -30,26 +32,44 @@ class Cef {
|
|||||||
? [RageFW_CefArguments<EventName>]
|
? [RageFW_CefArguments<EventName>]
|
||||||
: []
|
: []
|
||||||
): Promise<RageFW_CefReturn<EventName>> {
|
): Promise<RageFW_CefReturn<EventName>> {
|
||||||
|
if ('mp' in window) {
|
||||||
return rpc.call(eventName, args)
|
return rpc.call(eventName, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.reject(
|
||||||
|
'RageFW was started in window which not contain global variable MP!',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
public triggerServer<EventName extends keyof RageFW_ICustomServerEvent>(
|
public triggerServer<EventName extends keyof RageFW_ICustomServerEvent>(
|
||||||
eventName: EventName,
|
eventName: EventName,
|
||||||
...args: _ServerEventHasArgs<EventName> extends true
|
...args: _ServerEventHasArgs<EventName> extends true
|
||||||
? [RageFW_ServerArguments<EventName>]
|
? [RageFW_ServerArguments<EventName>]
|
||||||
: []
|
: []
|
||||||
): Promise<RageFW_ServerReturn<EventName>> {
|
): Promise<RageFW_ServerReturn<EventName>> {
|
||||||
|
if ('mp' in window) {
|
||||||
return rpc.callServer(eventName, args)
|
return rpc.callServer(eventName, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.reject(
|
||||||
|
'RageFW was started in window which not contain global variable MP!',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
public triggerClient<EventName extends keyof RageFW_ICustomClientEvent>(
|
public triggerClient<EventName extends keyof RageFW_ICustomClientEvent>(
|
||||||
eventName: EventName,
|
eventName: EventName,
|
||||||
...args: _ClientEventHasArgs<EventName> extends true
|
...args: _ClientEventHasArgs<EventName> extends true
|
||||||
? [RageFW_ClientArguments<EventName>]
|
? [RageFW_ClientArguments<EventName>]
|
||||||
: []
|
: []
|
||||||
): Promise<RageFW_ClientReturn<EventName>> {
|
): Promise<RageFW_ClientReturn<EventName>> {
|
||||||
|
if ('mp' in window) {
|
||||||
return rpc.callClient(eventName, args)
|
return rpc.callClient(eventName, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Promise.reject(
|
||||||
|
'RageFW was started in window which not contain global variable MP!',
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fw = {
|
export const fw = {
|
||||||
|
Loading…
Reference in New Issue
Block a user