Archived
init
This commit is contained in:
+12
-12
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "rage-fw-example-client",
|
||||
"description": "Client side of Rage-FW example",
|
||||
"scripts": {
|
||||
"build": "esbuild src/index.ts --bundle --platform=node --outfile=../../server/client_packages/index.js --format=esm"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rage-fw/shared": "workspace:^",
|
||||
"@entityseven/rage-fw-rpc": "0.2.5"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Entity Seven Group",
|
||||
"version": "0.1.0"
|
||||
"name": "rage-fw-example-client",
|
||||
"description": "Client side of Rage-FW example",
|
||||
"scripts": {
|
||||
"build": "esbuild src/index.ts --bundle --platform=node --outfile=../../server/client_packages/index.js --format=esm"
|
||||
},
|
||||
"dependencies": {
|
||||
"@rage-fw/shared": "workspace:^",
|
||||
"@entityseven/rage-fw-client": "0.2.0"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "Entity Seven Group",
|
||||
"version": "0.1.0"
|
||||
}
|
||||
|
||||
+11
-18
@@ -1,22 +1,15 @@
|
||||
import { events } from '@rage-fw/shared'
|
||||
import { rpc } from './lib'
|
||||
import { fw } from '@entityseven/rage-fw-client'
|
||||
|
||||
rpc.browser = mp.browsers.new('package://cef/index.html')
|
||||
fw.player.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'
|
||||
})
|
||||
fw.event.register('cefReady', async () => {
|
||||
fw.system.log.info('cefReady')
|
||||
|
||||
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'
|
||||
const responseBrowser = await fw.player.triggerBrowser(
|
||||
'customBrowserEvent',
|
||||
['from client'],
|
||||
)
|
||||
fw.system.log.info(responseBrowser)
|
||||
|
||||
await fw.player.triggerServer('customServerEvent', ['from client'])
|
||||
})
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import { Rpc } from '@entityseven/rage-fw-rpc'
|
||||
|
||||
export const rpc = new Rpc({
|
||||
debugLogs: true,
|
||||
})
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"baseUrl": "./src",
|
||||
"types": [
|
||||
"../../node_modules/@ragempcommunity/types-client",
|
||||
"../shared/declarations/rage-fw-shared-types/"
|
||||
]
|
||||
}
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"resolveJsonModule": true,
|
||||
"baseUrl": "./src",
|
||||
"types": [
|
||||
"../../node_modules/@ragempcommunity/types-client",
|
||||
"../shared/declarations/rage-fw-shared-types/"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user