Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. kpotschi
    kpotschi

    kpotschi

    @kpotschi

    Chat Follow Unfollow
    0
    Reputation
    2
    Posts
    177
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Continue chat with kpotschi
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    kpotschi Follow

    Posts made by kpotschi

    RE: Schema architecture and problems listening

    @coco nope - everything smooth, it's just the client not getting a signal that this.room.state.board has changed

    posted in Questions & Help •
    Schema architecture and problems listening

    Hey everyone.
    Working on a tiny prototype, I'm running into a problem that I can't seem to solve on my own: Changes in state by the server are triggered when running the ser/client combo locally, but not when in production (with arena).

    For the simplicity of it, think of it as a TicTacToe game with the following Schema

    export class TicTacTwistState extends Schema {
    	@type('number') gameState: GAMESTATE = GAMESTATE.WAITING
    	@type('string') currentTurn: string
    	@type('string') winner: string = ''
    	@type({ map: Player }) players = new MapSchema<Player>()
    	@type([BoardField]) board = new ArraySchema<BoardField>(
    		new BoardField(0),
    		new BoardField(1),
    		new BoardField(2),
    		new BoardField(3),
    		new BoardField(4),
    		new BoardField(5),
    		new BoardField(6),
    		new BoardField(7),
    		new BoardField(8),
    	)
    
    export class BoardField extends Schema {
    	@type(Marker) marker: Marker
    	@type('number') index: number
    	@type('boolean') trigger: boolean = true
    
    	constructor (index: number) {
    		super()
    		this.index = index
    	}
    }
    
    export class Marker extends Schema {
    	@type('number') size: MarkerSizes
    	@type('string') owner: string = ''
    	@type('boolean') isLocked = false
    	@type('number') color: number
    	constructor (size: MarkerSizes, color?: number, shape?: MarkerShape, owner?: string) {
    		super()
    		this.size = size
    		this.color = color
    		this.owner = owner
    	}
    }
    

    I do understand, that this is like deeply nested, but would that in general cause problems? Is there anything I can do better here? If not, I'm wondering if the is the right way to listen to changes client-side:

    this.room.state.board.forEach(
    	field =>
    		(field.onChange = changes => {
    			changes.forEach(change => {
    				if (change.field === 'marker') {
    //do stuff here
    				}
    			})
    		}),
    )
    

    Weird thing is, that it seems to work locally, but once deployed, the whole (deep) board state does not trigger.

    Thanks in advance for any ideas on this :) happy to provide more code if neccessary.

    posted in Questions & Help •