Apologies for the delayed response, I'm not sure why this went unanswered for this long. To answer your question a custom query can be used to further refine the match making process. It allows you to query the participant data of a pending match. Here's a basic example for you using countries. You can try this yourself by opening two test harness windows and logging in as two different players.
//player one sends a MatchMakingRequest with the participantData set to {"country":"ireland"}
{
"@class": ".MatchmakingRequest",
"participantData": {"country":"ireland"},
"matchShortCode": "testMatch",
"skill": 2
}
//player two then sends a MatchMakingRequest with the custom query set up to look for a match with the country set to Ireland.
{
"@class": ".MatchmakingRequest",
"customQuery": {"players.participantData.country":"ireland"},
"matchData": {},
"matchShortCode": "testMatch",
"skill": 2
}
In this instance the players will be matched. If you were to repeat the process with player 2 set to query for the "UK" both players would get a MatchNotFoundMessage. I hope that clears that up for you. If you have any further questions just let us know.
Apologies for the delayed response, I'm not sure why this went unanswered for this long. To answer your question a custom query can be used to further refine the match making process. It allows you to query the participant data of a pending match. Here's a basic example for you using countries. You can try this yourself by opening two test harness windows and logging in as two different players.
//player one sends a MatchMakingRequest with the participantData set to {"country":"ireland"}
{
"@class": ".MatchmakingRequest",
"participantData": {"country":"ireland"},
"matchShortCode": "testMatch",
"skill": 2
}
//player two then sends a MatchMakingRequest with the custom query set up to look for a match with the country set to Ireland.
{
"@class": ".MatchmakingRequest",
"customQuery": {"players.participantData.country":"ireland"},
"matchData": {},
"matchShortCode": "testMatch",
"skill": 2
}
In this instance the players will be matched. If you were to repeat the process with player 2 set to query for the "UK" both players would get a MatchNotFoundMessage. I hope that clears that up for you. If you have any further questions just let us know.
Thanks,
Liam
2 people like this
M
Mohamed Mohamed
said
almost 6 years ago
very good answer but here i have another issue
the best way to make a custom match between 2 players is to make a custom query like this with id like this :
//player one sends a MatchMakingRequest with the participantData set to {"country":"ireland"}{"@class":".MatchmakingRequest","Id":{"_Id":"...."},"matchShortCode":"testMatch","skill":2}//player two then sends a MatchMakingRequest with the custom query set up to look for a match with the country set to Ireland.{"@class":".MatchmakingRequest","customQuery":{"players.Id._Id":"...."},"matchData":{},"matchShortCode":"testMatch","skill":2}
or the another way is on cloud code by adding the 2 players id like this :
var matchId = Spark.getMultiplayer().createMatchById(playerId1, playerId2);
N
Nicholas Gallo
said
almost 5 years ago
Can you give an example of a MatchmakingRequest().SetCustomQuery(customQuery) in unity? Or should we use cloud code exclusively?
G
Guy Smith
said
almost 5 years ago
Example of Matchmaking request custom query in unity:
MatchmakingRequest request = new MatchmakingRequest();
request.SetMatchShortCode("CustomMatch");
request.SetSkill(0);
string jsonString = "{\"$in\":[\"5a58dd107eebc044b8ea0f57\"]}";
GSRequestData customQuery = new GSRequestData().AddJSONStringAsObject("players.playerId", jsonString);
request.SetCustomQuery(customQuery);
request.Send(OnMatchmakingSuccess, OnMatchmakingError);
The above custom query would be the equivalent of this in the test harness:
Vsevolod Miroshnikov
Please give an example of customQuery in MatchmakingRequest for Unity and json
https://docs.gamesparks.com/api-documentation/request-api/multiplayer/matchmakingrequest.html
Hi Vsevolod,
Apologies for the delayed response, I'm not sure why this went unanswered for this long. To answer your question a custom query can be used to further refine the match making process. It allows you to query the participant data of a pending match. Here's a basic example for you using countries. You can try this yourself by opening two test harness windows and logging in as two different players.
In this instance the players will be matched. If you were to repeat the process with player 2 set to query for the "UK" both players would get a MatchNotFoundMessage. I hope that clears that up for you. If you have any further questions just let us know.
Thanks,
Liam
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Vsevolod,
Apologies for the delayed response, I'm not sure why this went unanswered for this long. To answer your question a custom query can be used to further refine the match making process. It allows you to query the participant data of a pending match. Here's a basic example for you using countries. You can try this yourself by opening two test harness windows and logging in as two different players.
In this instance the players will be matched. If you were to repeat the process with player 2 set to query for the "UK" both players would get a MatchNotFoundMessage. I hope that clears that up for you. If you have any further questions just let us know.
Thanks,
Liam
2 people like this
Mohamed Mohamed
very good answer but here i have another issue
the best way to make a custom match between 2 players is to make a custom query like this with id like this :
or the another way is on cloud code by adding the 2 players id like this :
Nicholas Gallo
Can you give an example of a MatchmakingRequest().SetCustomQuery(customQuery) in unity? Or should we use cloud code exclusively?
Guy Smith
There are also more types you can add to the query. eg:"customQuery":{"players.playerId":{"$in":["5a58dd107eebc044b8ea0f57"]}}
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics