GitHub Documentation Patreon donate button

With the 0.10 schema release, has changing the state in the server changed?



  • I'm looking to update to the latest version of Colyseus, both in terms of the version and the new schema method of handling state.

    The documentation has instructions on how to listen to state change for clients, and how to define the schema for state, but there isn't any documentation on modifying state in the server. Is this because the method is the same as in 0.9?

    Example code:

    this.state.PlayerList[client.id].AnswerPicked = true;

    Schema

    class TriviaState extends Schema {

    constructor () {
    
        super();
    
        this.CurrentQuestion = new QuestionState();
        this.PlayerList = new ArraySchema();
    }
    

    }
    type(QuestionState)(TriviaState.prototype, "CurrentQuestion");
    type([PlayerState])(TriviaState.prototype, "PlayerList");


  • administrator

    Hey @KG204, yes! State mutations look exactly the same as they used to on previous versions! Cheers!


 

GitHub Documentation Patreon donate button

© 2019 Endel Dreyer