Version: 2019.2
Method group is Obsolete

NetworkMatch.JoinMatch

Switch to Manual
Obsolete public Coroutine JoinMatch (Networking.Types.NetworkID netId, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForClient, int requestDomain, DataResponseDelegate<MatchInfo> callback);

Parameters

netIdThe NetworkID of the match to join. This is found through calling NetworkMatch.ListMatches and picking a result from the returned list of matches.
matchPasswordThe password of the match. Leave empty if there is no password for the match, and supply the text string password if the match was configured to have one of the NetworkMatch.CreateMatch request.
publicClientAddressThe optional public client address. This value will be stored on the matchmaker and given to other clients listing matches. You should send this value if you want your players to be able to connect directly with each other over the internet. Alternatively you can pass an empty string and it will not affect the ability to interface with matchmaker or use relay server.
privateClientAddressThe optional private client address. This value will be stored on the matchmaker and given to other clients listing matches. You should send this value if you want your players to be able to connect directly with each other over a Local Area Network. Alternatively you can pass an empty string and it will not affect the ability to interface with matchmaker or use relay server.
eloScoreForClientThe Elo score for the client joining the match being created. If this number is set on all clients to indicate relative skill level, this number is used to return matches ordered by those that are most suitable for play given a listing player's skill level. This may be 0 on all clients, which would disable any Elo calculations in the MatchMaker.
requestDomainThe request domain for this request. Only requests in the same domain can interface with each other. For example if a NetworkMatch.CreateMatch is made with domain 1, only ListMatches that also specify domain 1 will find that match. Use this value to silo different (possibly incompatible) client versions.
callbackThe callback to be invoked when this call completes.

Returns

Coroutine This function is asynchronous and will complete at some point in the future, when the coroutine has finished communicating with the service backend.

Description

The function used to tell MatchMaker the current client wishes to join a specific match.

This function should be called after getting results from a call to NetworkMatch.ListMatches and picking a match to join. Upon receiving this request, the MatchMaker will reserve a seat on the Relay server this match is talking through and fetch the info needed for this client to connect to that Relay server. Once the callback completes, this client will have the necessary to continue connecting to the chosen match. To do so you then should call StartClient() with the passed in MatchInfo.

using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Networking.Match;
using UnityEngine.Networking.Types;

public class ExampleScript : MonoBehaviour { public NetworkID netId;

void Start() { NetworkManager.singleton.StartMatchMaker(); NetworkManager.singleton.matchMaker.JoinMatch(netId, "" , "", "", 0, 0, OnMatchJoined); }

public void OnMatchJoined(bool success, string extendedInfo, MatchInfo matchInfo) { // ... } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961