Match make with the Quick Join API
Quickly match make players using Lobby's Quick Join.
読み終わるまでの所要時間 1 分最終更新 3ヶ月前
Use the Lobby service to have a player randomly join any
session that's compatible with the parameters and filters passed to the method.
MatchmakeSessionAsyncThe following example demonstrates how to find and join a session in a single operation:
var quickJoinOptions = new QuickJoinOptions(){ Filters = new List<FilterOption> { new(FilterField.AvailableSlots, "1", FilterOperation.GreaterOrEqual), new (FilterField.StringIndex1, "map 1", FilterOperation.Equal) }, Timeout = TimeSpan.FromSeconds(5), CreateSession = true};var sessionOptions = new SessionOptions(){ MaxPlayers = 2, Type = "Session",}.WithRelayNetwork();ISession session = await MultiplayerService.Instance.MatchmakeSessionAsync(quickJoinOptions, sessionOptions);
This code tries to join a session that has at least available slot and the property .
continues searching for a session until the set timeout of is reached.
1map 1MatchmakeSessionAsync5 secondsAt this point, if the player can't join a session for any reason, such as all available sessions being full, the quick join operation can optionally create a new session using the parameter.
Note that the new session is only created after the set timeout has expired, if set.
CreateSessionWhen the quick join operation finds or creates a session, it configures networking to use Relay connections.