Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. game-libgdx-unity
    3. Posts
    • Profile
    • More
      • Continue chat with game-libgdx-unity
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups

    Posts made by game-libgdx-unity

    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]));
                }
            });
    
    posted in Questions & Help •