rage-framework-example/apps/client/src/index.ts
2024-10-28 10:28:56 +00:00

23 lines
687 B
TypeScript

import { events } from '@rage-fw/shared'
import { rpc } from './lib'
rpc.browser = mp.browsers.new('package://cef/index.html')
rpc.register(events.client.cefReady, async (args: string) => {
mp.console.logInfo(args)
const res = (await rpc.callServer(events.server.customServerEvent, [
'hello from client',
])) as string
mp.console.logInfo(res)
return 'response from client'
})
rpc.register(events.client.cefReady, async (args: string) => {
mp.console.logInfo(args)
const res = (await rpc.callBrowser(events.browser.customBrowserEvent, [
'hello from client',
])) as string
mp.console.logInfo(res)
return 'response from client'
})