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. kodypeterson
K

kodypeterson

@kodypeterson

Chat Follow Unfollow
0
Reputation
6
Posts
1.3k
Profile views
0
Followers
0
Following
Joined 7 Jul 2018, 20:06 Last Online 16 Aug 2018, 19:28

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

Posts made by kodypeterson

RE: Scaling

@endel So, I got this working by calling gameServer.matchMaker.create("game", {}); after registering (I only do this on the second process).

It seems that the you are only subscribing to presence when the room is created. There is no knowledge that a registered handler is registered within presence. So, I have manually created the room on startup.

This probably is not the best way, but it works for now while you can think about how we would want to solve for making the other game servers aware that a room is registered but not yet created.

posted in Questions & Help • 7 Jul 2018, 21:43
RE: Scaling

@endel ok this is where I am at. Still no good:

const gameServer = new colyseus.Server({
        verifyClient: (info, next) => {
            // console.log("custom verifyClient!");
            next(true);
        },
        presence: new colyseus.RedisPresence()
    });
    if (args.room) {
        gameServer.register("game", roomHandlers["game"]);
    } else {
        gameServer.register("game", roomHandlers["noop"]);
    }
    gameServer.attach({ server: httpServer });
    
    if (args.room) {
        gameServer.listen(port+1);
    } else {
        gameServer.listen(port);
    }

    console.log(`Listening on http://localhost:${ port }`);

I am still doing the noop thing so that I can force colyseus to try and use the second process.

posted in Questions & Help • 7 Jul 2018, 20:56
RE: Scaling

@endel This does not seem to be the case. I have created a "noop" handler now. Essentially just returns false for onRequestJoin and still the other process does not get triggered.

if (args.room) {
    console.log ('MODE: ROOM');
    console.log ('ROOM: ' + args.room);

    const gameServer = new colyseus.Server({
        presence: new colyseus.RedisPresence()
    });
    gameServer.register("game", roomHandlers["game"]);
} else {
    console.log ('MODE: MANAGER');
    // This is the main and manager

    const gameServer = new colyseus.Server({
        presence: new colyseus.RedisPresence()
    });
    gameServer.register("game", roomHandlers["noop"]);
    gameServer.attach({ server: httpServer });
    gameServer.listen(port);

    console.log(`Listening on http://localhost:${ port }`);
}
posted in Questions & Help • 7 Jul 2018, 20:37
RE: Scaling

@endel Maybe some example code from my end to help:

if (args.room) {
    console.log ('MODE: ROOM');
    console.log ('ROOM: ' + args.room);

    const gameServer = new colyseus.Server({
        presence: new colyseus.RedisPresence()
    });
    gameServer.register(args.room, roomHandlers[args.room]);
} else {
    console.log ('MODE: MANAGER');
    // This is the main and manager

    const gameServer = new colyseus.Server({
        presence: new colyseus.RedisPresence()
    });
    // gameServer.register("game", roomHandlers["game"]);
    gameServer.attach({ server: httpServer });
    gameServer.listen(port);

    console.log(`Listening on http://localhost:${ port }`);
}

I would run this process twice. One without the room argv and another with.

posted in Questions & Help • 7 Jul 2018, 20:23
RE: Scaling

@endel thanks for the response. I understand this. I am trying to figure out what the code looks like on a process that is only managing a room.

I am using redis for presence. But I can't seem to get another process that only manages a room going.

posted in Questions & Help • 7 Jul 2018, 20:21
Scaling

Are there any code examples on how to achieve this on the server side? From what it seems I have to run a websocket server on each machine/process? I would expect to be able to have a master process that handles all incoming websocket connections and then just proxies them to the other processes/machines for the rooms running there to handle. Maybe I am missing something?

posted in Questions & Help • 7 Jul 2018, 20:09

© 2023 Endel Dreyer