For the moment, there is no ready-made solution but here is a possibility
In src/modules/main/client/index.ts
import { RpgClient, RpgModule, RpgSprite, RpgClientEngine } from '@rpgjs/client'
let _socket: any
@RpgModule<RpgClient>({
sprite: {
onInit(sprite: RpgSprite) {
sprite.interactive = true
sprite.on('pointerdown', (position) => {
_socket.emit('click')
})
}
},
engine: {
onConnected(rpgEngine: RpgClientEngine, socket: any) {
_socket = socket
}
}
})
export default class RpgClientModuleEngine {}
An server side:
src/modules/main/server/player.ts
import { RpgPlayer,RpgPlayerHooks } from '@rpgjs/server'
export const player: RpgPlayerHooks = {
onConnected(player: RpgPlayer) {
player.on('click', () => {
console.log(player.id)
})
}
}