GitHub Documentation Patreon donate button

How to listen to changes from server-side?



  • Hi I'm using unity client,

    On the server-side I set

    constructor() {
            super();
            this.setState({
                players: {},
                messages: [],
                turn: 0
            });
        }
    
    update() {
    for (var id in this.state.players) {
                this.state.players[id].score += 1;
            }
    }
    

    In the client side how to listen to changes on player scores?
    I tried those code but can't get it done, examples:

     room.Listen("players/:id/score", change => {
                print("Operation " + change.operation);
                print("New player update " + change.value);
    
                foreach (var key in change.path.Keys)
                {
                    print(string.Format("{0}: {1}", key, change.path[key]));
                }
            });
    

    or

     room.Listen("players/:id/:*", change =>
            {
                print("Operation " + change.operation);
                print("New player update " + change.value);
    
                foreach (var key in change.path.Keys)
                {
                    print(string.Format("{0}: {1}", key, change.path[key]));
                }
            });
    

 

GitHub Documentation Patreon donate button

© 2019 Endel Dreyer