question

Dmitrii Osipov avatar image
Dmitrii Osipov asked

Find nearby users (by location, country, continent)

Hello.

I'm currentlu working on a p2p multiplayer game and want to find way to connect users to each other without using master servers and other similar solutions. The flow i designed is:

1. User starts game (set's player data value to mark it as ready to play or something similar, maybe add to some shared group) and starts continuour request sequence (1 per sec) to receive status.

2. Matchmaker (cloud script actually, called after join) search for nearby users (if it possible actually) and sets some data to both of them (who is master, ip's and ports and etc)

2.1 If no users found within 1st iteration range wait for a next iteration and increase search range.

2.2 if there were some users and pair were found go to p3.

3. Players connects to each other and play short p2p match.

4. On match end master client posts results to playfab.

So the main problem is to find logged in users with some specified flag near to each other.

The solution is can be in SharedGroups and its data to store waiting player with they login location data and iterate on every join, but idk if there some limitations of SharedGroupData size and players count.

Maybe there are some more elegant way to solve it?

If there are not, can i use Matchmaker API (custom implemented server) to use it as p2p matchmaker?

Matchmaking
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

Well first, no, Shared Groups cannot be used as a matchmaker. Shared Group Data is effectively player data with no specific player owner - it is intended to be used for sharing data between a small number of players, and was originally added for asynchronous, turn-based games to use to share game state. Matchmakers require the ability to update at a high rate of speed, and using data for a large number of players simultaneously - as such, they normally are in-memory systems, running on dedicated servers.

The existing PlayFab matchmaker is designed to find the first available slot in a game matching the input parameters (game mode, region, build), and it can optionally use a statistic to order the results, so that you match players with similar skill. It is also only usable for games that use hosted custom game servers. To build a matchmaker which uses geolocation as a primary component, you would need to use our Matchmaker API in a custom server you build, which takes into account the location of players (which you can get from their profile data). But again, the design of that API is intended for games using custom game servers.

In general, we recommend Photon Realtime for games that require matchmaking, but don't use custom game servers, as it provides a lighter-weight option. However, their matchmaker also does not provide a way to make the physical distance between players be a primary search component, but if you can be more granular (making it be down to the region or country of the player), you could filter players for that: https://doc.photonengine.com/en/realtime/current/reference/matchmaking-and-lobby#not_so_random_matchmaking

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dmitrii Osipov avatar image Dmitrii Osipov commented ·

Ok, i got it.

In general i try to avoid usage of self hosted server to make matchmaking logic, also the only thing i need is logic to make p2p connection between users based first of all on their geo location.

I decided to implement dedicated self hosted server based on web requests or something similar and matchmake players based on User's LoginLocation data.

Granulating users to groups will cause some problems in small amound of users (1 player in single group will never find a match).

Thanks again for help to decide.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.