GitHub Documentation

Server State Class How To Reference Room

  • My server does this in onInit():

    this.setState(new Game())

    I want the Game class to be able to call broadcast on the room.
    If I do in onInit(), then this will be a part of the state and broadcast to the clients, which I don't want.
    How can I pass a room reference to the room state without having it be a part of the serialized state?

    I'm using the old serializer if it matters.

    The reason I need to do this is because my state class handles all the game logic, and the room is basically a wrapper around the state.

  • gladiator

    First off, you shouldn't do this. It's meant to be a state, which holds data. Not a lot more than that.

    That said, if you really want to, you can add a @nonenumerable or @nosync attribute to the room variable. to make it not serialized.


© 2021 Lucid Sight, Inc