Navigation

  • Recent
  • Tags
  • Users
  • Search
  • Login
Colyseus
  • Login
  • Search
  • Recent
  • Tags
  • Users

Documentation GitHub

We're migrating to GitHub Discussions. This forum does not accept new registrations since April 6, 2023.
  1. Home
  2. atzmael
  3. Posts
  • Profile
  • More
    • Continue chat with atzmael
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

Posts made by atzmael

RE: Uncaught Error: ChangeTree: missing index for field "undefined"

Hi @endel ! Thanks

thank for answering, I'm not using @filter() or @filterChildren().

Here is the code of the MapSchema :

export class Joker extends Schema {
    @type("string")
    type: string;

    @type("string")
    slug: string;

    @type("string")
    name: string;

    @type("boolean")
    available: boolean = true;

    @type("boolean")
    isUsed: boolean = false;
}

and it's inplementation in the Schema for the Player

@type({ map: Joker })
jokers: MapSchema<Joker>;

I initialize it here (maybe here is the bad code haha) :

let jokers = new MapSchema<Joker>();
    this.jokers.forEach((jk) => {
        let joker = new Joker({
        type: jk.type,
        slug: jk.slug,
        name: jk.name,
        available: true,
        isUsed: false
    });
    jokers.set(jk.slug, joker);
})

the jokers array

jokers = [
        { type: 'bonus', slug: "cdp", name: "Coup d'pouce" },
        { type: 'attaque', slug: "pjn", name: "Petit jaune" },
    ];

And the error throws when I do this :
this.state.players.get(client.sessionId).jokers.get(packet.datas).available = false;

Just to know, I use this.state.players.get(client.sessionId).jokers.get(packet.datas).available in a if right before and it doesn't throw error.
Plus, the error is throwing on client-side in colyseus.js and nothing shows up on server-side.

Hope it will help !

Cheers!

posted in Questions & Help • 19 Jun 2021, 09:30
Uncaught Error: ChangeTree: missing index for field "undefined"

Hello everyone,

I'm currently building a web game (based on colyseus and VueJS).

I had no problem at all during the whole development, but today I just saw this error pop in the console at a specific moment.
error-colyseus.png
It does not block the code and execution.
It is due to this line of code, server-side, in a listener for client request

this.state.players.get(client.sessionId).jokers.get(packet.datas).available = false;

I have tried to write it that way but the error is still here

let player = this.state.players.get(client.sessionId);
let joker = player.jokers.get(packet.datas);
joker.available = false;

the property jokers is a mapSchema binded with jokers "slug" so it's easy to find them.

Why is it causing an error and do you have a tip to avoid it ?

Thanks !
Maël

posted in Questions & Help • 16 Jun 2021, 15:35

© 2023 Endel Dreyer