GitHub Documentation Patreon donate button

Is it possible to run `joinOrCreateById`?



  • Hey all - I'm trying to figure out some matchmaking/lobby creation flows and I was wondering:

    can I use joinOrCreateById?

    Thanks in advance!


  • administrator

    Hi @LukeWood, welcome!

    You'd be better off setting a filter for matchmaking, and use joinOrCreate() normally.

    First, you need to define your room, with the "code" filter (you can use any identifier, I'm using "code" just for the sake of this explanation).

    The filterBy() below means that the available list of rooms is going to be filtered accourding to the options provided by the client. (See the docs)

    gameServer
      .define("match", MyMatch)
      .filterBy(["code"]);
    

    Then, you can have an "code" provided by the client-side, and provide it to .joinOrCreate("match", { code: "ABCD" }).

    There are many ways to achieve that - you may need a service to make sure these ids are unique, or you can just generate long enough ids in the client-side and hope they won't collide.

    Hope this helps, cheers!



  • @endel very cool! I see how that’s handled now.

    Also very handy to know about the filtering features :). It seems could be really useful in implementing some sort of ranked matchmaking service.


 

GitHub Documentation Patreon donate button

© 2020 Endel Dreyer