Navigation

    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Users
    1. Home
    2. kotwys
    • Continue chat with kotwys
    • Start new chat with kotwys
    • Flag Profile
    • block_user
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups
    Save
    Saving

    kotwys

    @kotwys

    1
    Reputation
    3
    Posts
    107
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online
    Location Izh kar

    kotwys Follow

    Posts made by kotwys

    • RE: room.OnMessage not registered for Schema message: MyMessage

      The message itself contains only data so it isn’t used to detect the message type (you’re trying to catch “readyToStart” messages, right?).

      I don’t know how Unity client works but as I could understand it separates messages by classes names if not specified. So maybe this should look like this:

      room.OnMessage<MyMessage>("MyMessage", (message) => {
        // your code
      });
      
      posted in Questions & Help
      kotwys
    • RE: MapSchema items don't get to the client

      Okay, then I’ll wait. I ran ahead a little :)

      Thank you @endel for you work!

      posted in Questions & Help
      kotwys
    • MapSchema items don't get to the client

      Hello, It’s the first time I’m using Colyseus and I ran into problem.

      The code for both client and server is written with Haxe. Also I had to switch to alpha 0.14 because Haxe client didn't tolerate “none” states on 0.13.

      I have a MapSchema in state. Whenever I update the map, it gets updated properly on the server and onStateChanged event is raised on the client, but the map on the client itself remains empty and consequently on{Add,Remove} events don’t appear.

      I have the following code:

      Room handler

      import kakto.common.schema.WalkableState;
      
      class Walkable extends Room {
        override function onCreate(o:Map<String, Dynamic>) {
          setState(new WalkableState());
        }
      
        override function onJoin(client:Client, ?o:Map<String, Dynamic>, ?auth:Dynamic) {
          (state:WalkableState).players.set(client.sessionId, new Player());
          return null;
        }
      }
      

      Schema

      Schema file is common for both client and server with packages changed using conditional compilation. Maybe this is the root of the problem?

      #if hxnodejs
      import colyseus.server.schema.Schema;
      #else
      import io.colyseus.serializer.schema.Schema;
      import io.colyseus.serializer.schema.MapSchema;
      #end
      
      class Player extends Schema {}
      
      class WalkableState extends Schema {
        // There may be anything instead of `Player` type
        #if hxnodejs
        @:type({ map: Player })
        #else
        @:type('map', Player)
        #end
        public var players = new MapSchema<Player>();
      
        #if hxnodejs
        public function new() {}
        #end
      }
      

      Client

      room.onStateChange += (state:WalkableState) -> {
        trace(state.players); // always empty Map
      };
      
      // these two don't get called at all
      room.state.players.onAdd = (player, id) -> {
        trace('$id joined');
      };
      
      room.state.players.onRemove = (player, id) -> {
        trace('$id quit');
      };
      

      Thanks.

      posted in Questions & Help
      kotwys