Open tobiasstrebitzer opened 3 years ago
This Pull Request allows automatic serialization of Schema data when using the room.send method.
room.send
class UpdateArgs extends Schema { @type('uint8') x: number @type('uint8') y: number } const updateArgs = new UpdateArgs({ x: 1, y: 2 }) room.send(updateArgs)
class UpdateArgs extends Schema { @type('uint8') x: number @type('uint8') y: number } class GameRoom extends Room { async onCreate() { this.onMessage(UpdateArgs, (client, args) => { console.log(args) // UpdateArgs { x: 1, y: 2 } console.log(args instanceof UpdateArgs) // true }) } }
colyseus
Client Example:
Server Example:
Notes:
colyseus
can be found here.