Navigation

    Colyseus
    • Login
    • Search
    • Recent
    • Tags
    • Users
    1. Home
    2. OrangeNote
    OrangeNote

    OrangeNote

    @OrangeNote

    Chat Follow Unfollow
    0
    Reputation
    2
    Posts
    972
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    • Profile
    • More
      • Continue chat with OrangeNote
      • Flag Profile
      • Following
      • Followers
      • Topics
      • Posts
      • Best
      • Groups
    OrangeNote Follow

    Posts made by OrangeNote

    RE: requestJoin called twice

    Thanks for the quick response and for the heads up about the join issue.

    But unfortunately that didn't answer my question. I'll explain my situation more clearly.

    I have added one console.log line to CreateOrJoinRoom.requestJoin method:

    requestJoin (options, isNewRoom: boolean) {
      console.log(`roomId: ${this.roomId}, create: ${options.create}, isNewRoom: ${isNewRoom}`);
      return (options.create)
        ? (options.create && isNewRoom)
        : this.clients.length > 0;
    }
    

    Then went to http://localhost:2567/04-create-or-join-room.html and pressed Create once, then Join once.

    This is what I got in the server console:

    Listening on http://localhost:2567
    JOINING ROOM
    roomId: BJl3OCrCWX, create: true, isNewRoom: true
    CREATING NEW ROOM
    roomId: BJl3OCrCWX, create: undefined, isNewRoom: false --
    roomId: BJl3OCrCWX, create: undefined, isNewRoom: false -- why is requestJoin called twice?
    CREATING NEW ROOM
    
    posted in Questions & Help •
    requestJoin called twice

    Hi,

    I was testing the example 04-create-or-join-room from colyseus-examples. I added some console.logs around and I noticed that requestJoin is not behaving as I would expect.

    Always referring to that example, if I ask to create one room from client client.join('create_or_join', { create: true }), I see one requestJoin, with option.create and isNewRoom both set to true. So far so good. Then using another client (or browser tab, the outcome is the same in both cases), I ask to join client.join('create_or_join'). I see that requestJoin is called twice for the same roomId (I assume that means the same CreateOrJoinRoom instance), both times with option.create set to undefined, as expected, and with isNewRoom set to false. Then I see one onJoin event associated to that roomId. colyseus/monitor lists one room with two clients connected.

    The question is: why is requestJoin called twice? The first (and only one) instance is never being locked and maxClient is set to 4. Funny thing, both requestJoins return true.

    I'm not sure I fully understood rooms and their interactions with clients, but I really want to make sure this is not a colyseus issue that might influence other parts of the code.

    posted in Questions & Help •