added browser trigger on client/server | added copyright on server
This commit is contained in:
parent
57b4f236ac
commit
79011e0fd2
@ -10,7 +10,11 @@ import {
|
||||
RageFW_ClientServerEventReturn,
|
||||
RageFW_ClientEventArguments,
|
||||
RageFW_ClientEventReturn,
|
||||
RageFW_CefEvent,
|
||||
RageFW_CefArgs,
|
||||
RageFW_CefReturn,
|
||||
} from './types'
|
||||
|
||||
import type { RageFW_ICustomClientEvent } from 'rage-fw-shared-types'
|
||||
|
||||
class Client {
|
||||
@ -28,6 +32,10 @@ class Client {
|
||||
): void {
|
||||
rpc.unregister(eventName)
|
||||
}
|
||||
}
|
||||
|
||||
class Player {
|
||||
public browser: BrowserMp | undefined
|
||||
|
||||
public trigger<EventName extends keyof RageFW_ICustomClientEvent>(
|
||||
eventName: EventName,
|
||||
@ -35,15 +43,27 @@ class Client {
|
||||
): Promise<RageFW_ClientEventReturn<EventName>> {
|
||||
return rpc.call<RageFW_ClientEventReturn<EventName>>(eventName, args)
|
||||
}
|
||||
}
|
||||
|
||||
class Player {
|
||||
public triggerServer<EventName extends RageFW_ClientServerEvent>(
|
||||
eventName: EventName,
|
||||
args: RageFW_ClientServerEventArguments<EventName>,
|
||||
): Promise<RageFW_ClientServerEventReturn<EventName>> {
|
||||
return rpc.callServer(eventName, args)
|
||||
}
|
||||
|
||||
public triggerBrowser<EventName extends RageFW_CefEvent>(
|
||||
eventName: EventName,
|
||||
args: RageFW_CefArgs<EventName>,
|
||||
): Promise<RageFW_CefReturn<EventName>> {
|
||||
if (!this.browser)
|
||||
throw new Error('You need to initialize browser first!')
|
||||
return rpc.callBrowser(this.browser, eventName, args)
|
||||
}
|
||||
|
||||
public registerBrowser(browser: BrowserMp) {
|
||||
this.browser = browser
|
||||
return browser
|
||||
}
|
||||
}
|
||||
|
||||
export const fw = {
|
||||
|
13
client/src/types/browser.ts
Normal file
13
client/src/types/browser.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/// <reference types="@ragempcommunity/types-client" />
|
||||
|
||||
import type { RageFW_ICustomCefEvent } from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_CefEvent = keyof RageFW_ICustomCefEvent
|
||||
|
||||
export type RageFW_CefArgs<K extends RageFW_CefEvent> = Parameters<
|
||||
RageFW_ICustomCefEvent[K]
|
||||
>
|
||||
|
||||
export type RageFW_CefReturn<K extends RageFW_CefEvent> = ReturnType<
|
||||
RageFW_ICustomCefEvent[K]
|
||||
>
|
@ -1,2 +1,3 @@
|
||||
export * from './client'
|
||||
export * from './server'
|
||||
export * from './browser'
|
||||
|
@ -3,6 +3,9 @@ import rpc from 'rage-rpc'
|
||||
import Logger from './logger'
|
||||
|
||||
import {
|
||||
RageFW_CefArgs,
|
||||
RageFW_CefEvent,
|
||||
RageFW_CefReturn,
|
||||
RageFW_ClientEvent,
|
||||
RageFW_ClientEventArguments,
|
||||
RageFW_ClientEventReturn,
|
||||
@ -115,6 +118,14 @@ class Player {
|
||||
): Promise<RageFW_ClientEventReturn<EventName>> {
|
||||
return rpc.callClient(player, eventName, args)
|
||||
}
|
||||
|
||||
public triggerBrowser<EventName extends RageFW_CefEvent>(
|
||||
player: PlayerMp,
|
||||
eventName: EventName,
|
||||
args: RageFW_CefArgs<EventName>,
|
||||
): Promise<RageFW_CefReturn<EventName>> {
|
||||
return rpc.callBrowsers(player, eventName, args)
|
||||
}
|
||||
}
|
||||
|
||||
export const fw = {
|
||||
@ -124,3 +135,7 @@ export const fw = {
|
||||
log: new Logger(),
|
||||
},
|
||||
}
|
||||
|
||||
fw.system.log.info(
|
||||
'Working on Rage Framework. RageFW © Powered by Entity Seven Group',
|
||||
)
|
||||
|
11
server/src/types/browser.ts
Normal file
11
server/src/types/browser.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import type { RageFW_ICustomCefEvent } from 'rage-fw-shared-types'
|
||||
|
||||
export type RageFW_CefEvent = keyof RageFW_ICustomCefEvent
|
||||
|
||||
export type RageFW_CefArgs<K extends RageFW_CefEvent> = Parameters<
|
||||
RageFW_ICustomCefEvent[K]
|
||||
>
|
||||
|
||||
export type RageFW_CefReturn<K extends RageFW_CefEvent> = ReturnType<
|
||||
RageFW_ICustomCefEvent[K]
|
||||
>
|
@ -1,2 +1,3 @@
|
||||
export * from './client'
|
||||
export * from './server'
|
||||
export * from './browser'
|
||||
|
Loading…
Reference in New Issue
Block a user