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. OrangeNote
  3. Posts
  • Profile
  • More
    • Continue chat with OrangeNote
    • Flag Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

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 • 25 Jun 2018, 11:17
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 • 24 Jun 2018, 09:57

© 2023 Endel Dreyer