Archived
feat pure rpc example
This commit is contained in:
1 parent
67be91538b
commit
e7e423adc6
38 files changed
+161
-707
No files matched your search
@@ -1,11 +1,20 @@
|
||||
import { rpc } from 'rpc'
|
||||
import { events } from '@rage-fw/shared'
|
||||
import { rpc } from './lib'
|
||||
|
||||
rpc.register('playerJoin', async (player: PlayerMp) => {
|
||||
console.log(`Connected: ${player.socialClub}`)
|
||||
console.log(`[Server] ${player.socialClub} connected`)
|
||||
})
|
||||
|
||||
rpc.register('customServerEvent', (player: PlayerMp, data) => {
|
||||
console.log(player, data)
|
||||
|
||||
rpc.callClient(player, 'customClientEvent', ['server to client'])
|
||||
})
|
||||
rpc.register(
|
||||
events.server.customServerEvent,
|
||||
async (player: PlayerMp, args: string) => {
|
||||
console.log(args)
|
||||
const res = await rpc.callClient(
|
||||
player,
|
||||
events.client.customClientEvent,
|
||||
['hello from server'],
|
||||
)
|
||||
console.log(res)
|
||||
return 'response from server'
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Rpc } from 'rage-fw-rpc'
|
||||
|
||||
export const rpc = new Rpc({
|
||||
debugLogs: true,
|
||||
})
|
||||
Reference in new issue
Block a user