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. elberto
elberto

elberto

@elberto

Chat Follow Unfollow
0
Reputation
3
Posts
1.0k
Profile views
0
Followers
0
Following
Joined 11 Dec 2019, 13:04 Last Online 30 Dec 2019, 11:06

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

Posts made by elberto

RE: Room.clients aren't Room.state.players

Hi @endel, thanks for your quick answer. I understand why I was struggling now !
With your fix, I still can't deliver my messages to all clients.
For now I did this on async for testing purposes, but it's really ugly and unreliable


if (this.hasReachedMaxClients()) { 
   setTimeout(async () => {
      for (let sessionId in this.clients) {
         this.send(this.clients[sessionId], { message: "Hello world!" });
      }
   }
},  1000);

If you have a better way, I'll take it !
Have a nice day !

posted in Questions & Help • 16 Dec 2019, 08:58
Room.clients aren't Room.state.players

Hi,
I'm trying to create a gameroom with a maxClients.(clients are deleted if the leave the room lobby). When it's reached, I want to lock the room and send each client their id in the game as player (that is their order in the Room.clients array).

The problem I face is the client is added to the array in a async task, so I can't immediately begin the task in the onJoin() method because the last client as not been added yet when onJoin() is called.

I can't seem to find a callback for the room when a client is effectively added to Room.clients, so I can send each client their player id (different from their client id and sessionId) in the game.

It's I think a basic question, but I can't figure it out. I'm new to multiplayer gameserver, so maybe I'm not thinking the right way.
Regards and thanks for any help.

posted in Questions & Help • 13 Dec 2019, 15:36

© 2023 Endel Dreyer