Files
Dec2017-Script-Dump/UnityEngine/Networking/Match/NetworkMatch.cs
T
2026-06-04 11:42:34 +02:00

405 lines
16 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using SimpleJson;
using UnityEngine.Networking.Types;
namespace UnityEngine.Networking.Match
{
// Token: 0x020002C1 RID: 705
public class NetworkMatch : MonoBehaviour
{
// Token: 0x17000AB2 RID: 2738
// (get) Token: 0x06002EB3 RID: 11955 RVA: 0x000437B8 File Offset: 0x000419B8
// (set) Token: 0x06002EB4 RID: 11956 RVA: 0x000437D4 File Offset: 0x000419D4
public Uri baseUri
{
get
{
return this.m_BaseUri;
}
set
{
this.m_BaseUri = value;
}
}
// Token: 0x06002EB5 RID: 11957 RVA: 0x000437E0 File Offset: 0x000419E0
[Obsolete("This function is not used any longer to interface with the matchmaker. Please set up your project by logging in through the editor connect dialog.", true)]
public void SetProgramAppID(AppID programAppID)
{
}
// Token: 0x06002EB6 RID: 11958 RVA: 0x000437E4 File Offset: 0x000419E4
public Coroutine CreateMatch(string matchName, uint matchSize, bool matchAdvertise, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForMatch, int requestDomain, NetworkMatch.DataResponseDelegate<MatchInfo> callback)
{
Coroutine coroutine;
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
Debug.LogError("Matchmaking is not supported on WebGL player.");
coroutine = null;
}
else
{
coroutine = this.CreateMatch(new CreateMatchRequest
{
name = matchName,
size = matchSize,
advertise = matchAdvertise,
password = matchPassword,
publicAddress = publicClientAddress,
privateAddress = privateClientAddress,
eloScore = eloScoreForMatch,
domain = requestDomain
}, callback);
}
return coroutine;
}
// Token: 0x06002EB7 RID: 11959 RVA: 0x00043864 File Offset: 0x00041A64
internal Coroutine CreateMatch(CreateMatchRequest req, NetworkMatch.DataResponseDelegate<MatchInfo> callback)
{
Coroutine coroutine;
if (callback == null)
{
Debug.Log("callback supplied is null, aborting CreateMatch Request.");
coroutine = null;
}
else
{
Uri uri = new Uri(this.baseUri, "/json/reply/CreateMatchRequest");
Debug.Log("MatchMakingClient Create :" + uri);
WWWForm wwwform = new WWWForm();
wwwform.AddField("version", Request.currentVersion);
wwwform.AddField("projectId", Application.cloudProjectId);
wwwform.AddField("sourceId", Utility.GetSourceID().ToString());
wwwform.AddField("accessTokenString", 0);
wwwform.AddField("domain", req.domain);
wwwform.AddField("name", req.name);
wwwform.AddField("size", req.size.ToString());
wwwform.AddField("advertise", req.advertise.ToString());
wwwform.AddField("password", req.password);
wwwform.AddField("publicAddress", req.publicAddress);
wwwform.AddField("privateAddress", req.privateAddress);
wwwform.AddField("eloScore", req.eloScore.ToString());
wwwform.headers["Accept"] = "application/json";
WWW www = new WWW(uri.ToString(), wwwform);
coroutine = base.StartCoroutine(this.ProcessMatchResponse<CreateMatchResponse, NetworkMatch.DataResponseDelegate<MatchInfo>>(www, new NetworkMatch.InternalResponseDelegate<CreateMatchResponse, NetworkMatch.DataResponseDelegate<MatchInfo>>(this.OnMatchCreate), callback));
}
return coroutine;
}
// Token: 0x06002EB8 RID: 11960 RVA: 0x000439F8 File Offset: 0x00041BF8
internal virtual void OnMatchCreate(CreateMatchResponse response, NetworkMatch.DataResponseDelegate<MatchInfo> userCallback)
{
if (response.success)
{
Utility.SetAccessTokenForNetwork(response.networkId, new NetworkAccessToken(response.accessTokenString));
}
userCallback(response.success, response.extendedInfo, new MatchInfo(response));
}
// Token: 0x06002EB9 RID: 11961 RVA: 0x00043A34 File Offset: 0x00041C34
public Coroutine JoinMatch(NetworkID netId, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForClient, int requestDomain, NetworkMatch.DataResponseDelegate<MatchInfo> callback)
{
return this.JoinMatch(new JoinMatchRequest
{
networkId = netId,
password = matchPassword,
publicAddress = publicClientAddress,
privateAddress = privateClientAddress,
eloScore = eloScoreForClient,
domain = requestDomain
}, callback);
}
// Token: 0x06002EBA RID: 11962 RVA: 0x00043A88 File Offset: 0x00041C88
internal Coroutine JoinMatch(JoinMatchRequest req, NetworkMatch.DataResponseDelegate<MatchInfo> callback)
{
Coroutine coroutine;
if (callback == null)
{
Debug.Log("callback supplied is null, aborting JoinMatch Request.");
coroutine = null;
}
else
{
Uri uri = new Uri(this.baseUri, "/json/reply/JoinMatchRequest");
Debug.Log("MatchMakingClient Join :" + uri);
WWWForm wwwform = new WWWForm();
wwwform.AddField("version", Request.currentVersion);
wwwform.AddField("projectId", Application.cloudProjectId);
wwwform.AddField("sourceId", Utility.GetSourceID().ToString());
wwwform.AddField("accessTokenString", 0);
wwwform.AddField("domain", req.domain);
wwwform.AddField("networkId", req.networkId.ToString());
wwwform.AddField("password", req.password);
wwwform.AddField("publicAddress", req.publicAddress);
wwwform.AddField("privateAddress", req.privateAddress);
wwwform.AddField("eloScore", req.eloScore.ToString());
wwwform.headers["Accept"] = "application/json";
WWW www = new WWW(uri.ToString(), wwwform);
coroutine = base.StartCoroutine(this.ProcessMatchResponse<JoinMatchResponse, NetworkMatch.DataResponseDelegate<MatchInfo>>(www, new NetworkMatch.InternalResponseDelegate<JoinMatchResponse, NetworkMatch.DataResponseDelegate<MatchInfo>>(this.OnMatchJoined), callback));
}
return coroutine;
}
// Token: 0x06002EBB RID: 11963 RVA: 0x00043BE8 File Offset: 0x00041DE8
internal void OnMatchJoined(JoinMatchResponse response, NetworkMatch.DataResponseDelegate<MatchInfo> userCallback)
{
if (response.success)
{
Utility.SetAccessTokenForNetwork(response.networkId, new NetworkAccessToken(response.accessTokenString));
}
userCallback(response.success, response.extendedInfo, new MatchInfo(response));
}
// Token: 0x06002EBC RID: 11964 RVA: 0x00043C24 File Offset: 0x00041E24
public Coroutine DestroyMatch(NetworkID netId, int requestDomain, NetworkMatch.BasicResponseDelegate callback)
{
return this.DestroyMatch(new DestroyMatchRequest
{
networkId = netId,
domain = requestDomain
}, callback);
}
// Token: 0x06002EBD RID: 11965 RVA: 0x00043C58 File Offset: 0x00041E58
internal Coroutine DestroyMatch(DestroyMatchRequest req, NetworkMatch.BasicResponseDelegate callback)
{
Coroutine coroutine;
if (callback == null)
{
Debug.Log("callback supplied is null, aborting DestroyMatch Request.");
coroutine = null;
}
else
{
Uri uri = new Uri(this.baseUri, "/json/reply/DestroyMatchRequest");
Debug.Log("MatchMakingClient Destroy :" + uri.ToString());
WWWForm wwwform = new WWWForm();
wwwform.AddField("version", Request.currentVersion);
wwwform.AddField("projectId", Application.cloudProjectId);
wwwform.AddField("sourceId", Utility.GetSourceID().ToString());
wwwform.AddField("accessTokenString", Utility.GetAccessTokenForNetwork(req.networkId).GetByteString());
wwwform.AddField("domain", req.domain);
wwwform.AddField("networkId", req.networkId.ToString());
wwwform.headers["Accept"] = "application/json";
WWW www = new WWW(uri.ToString(), wwwform);
coroutine = base.StartCoroutine(this.ProcessMatchResponse<BasicResponse, NetworkMatch.BasicResponseDelegate>(www, new NetworkMatch.InternalResponseDelegate<BasicResponse, NetworkMatch.BasicResponseDelegate>(this.OnMatchDestroyed), callback));
}
return coroutine;
}
// Token: 0x06002EBE RID: 11966 RVA: 0x00043D7C File Offset: 0x00041F7C
internal void OnMatchDestroyed(BasicResponse response, NetworkMatch.BasicResponseDelegate userCallback)
{
userCallback(response.success, response.extendedInfo);
}
// Token: 0x06002EBF RID: 11967 RVA: 0x00043D94 File Offset: 0x00041F94
public Coroutine DropConnection(NetworkID netId, NodeID dropNodeId, int requestDomain, NetworkMatch.BasicResponseDelegate callback)
{
return this.DropConnection(new DropConnectionRequest
{
networkId = netId,
nodeId = dropNodeId,
domain = requestDomain
}, callback);
}
// Token: 0x06002EC0 RID: 11968 RVA: 0x00043DD0 File Offset: 0x00041FD0
internal Coroutine DropConnection(DropConnectionRequest req, NetworkMatch.BasicResponseDelegate callback)
{
Coroutine coroutine;
if (callback == null)
{
Debug.Log("callback supplied is null, aborting DropConnection Request.");
coroutine = null;
}
else
{
Uri uri = new Uri(this.baseUri, "/json/reply/DropConnectionRequest");
Debug.Log("MatchMakingClient DropConnection :" + uri);
WWWForm wwwform = new WWWForm();
wwwform.AddField("version", Request.currentVersion);
wwwform.AddField("projectId", Application.cloudProjectId);
wwwform.AddField("sourceId", Utility.GetSourceID().ToString());
wwwform.AddField("accessTokenString", Utility.GetAccessTokenForNetwork(req.networkId).GetByteString());
wwwform.AddField("domain", req.domain);
wwwform.AddField("networkId", req.networkId.ToString());
wwwform.AddField("nodeId", req.nodeId.ToString());
wwwform.headers["Accept"] = "application/json";
WWW www = new WWW(uri.ToString(), wwwform);
coroutine = base.StartCoroutine(this.ProcessMatchResponse<DropConnectionResponse, NetworkMatch.BasicResponseDelegate>(www, new NetworkMatch.InternalResponseDelegate<DropConnectionResponse, NetworkMatch.BasicResponseDelegate>(this.OnDropConnection), callback));
}
return coroutine;
}
// Token: 0x06002EC1 RID: 11969 RVA: 0x00043F0C File Offset: 0x0004210C
internal void OnDropConnection(DropConnectionResponse response, NetworkMatch.BasicResponseDelegate userCallback)
{
userCallback(response.success, response.extendedInfo);
}
// Token: 0x06002EC2 RID: 11970 RVA: 0x00043F24 File Offset: 0x00042124
public Coroutine ListMatches(int startPageNumber, int resultPageSize, string matchNameFilter, bool filterOutPrivateMatchesFromResults, int eloScoreTarget, int requestDomain, NetworkMatch.DataResponseDelegate<List<MatchInfoSnapshot>> callback)
{
Coroutine coroutine;
if (Application.platform == RuntimePlatform.WebGLPlayer)
{
Debug.LogError("Matchmaking is not supported on WebGL player.");
coroutine = null;
}
else
{
coroutine = this.ListMatches(new ListMatchRequest
{
pageNum = startPageNumber,
pageSize = resultPageSize,
nameFilter = matchNameFilter,
filterOutPrivateMatches = filterOutPrivateMatchesFromResults,
eloScore = eloScoreTarget,
domain = requestDomain
}, callback);
}
return coroutine;
}
// Token: 0x06002EC3 RID: 11971 RVA: 0x00043F94 File Offset: 0x00042194
internal Coroutine ListMatches(ListMatchRequest req, NetworkMatch.DataResponseDelegate<List<MatchInfoSnapshot>> callback)
{
Coroutine coroutine;
if (callback == null)
{
Debug.Log("callback supplied is null, aborting ListMatch Request.");
coroutine = null;
}
else
{
Uri uri = new Uri(this.baseUri, "/json/reply/ListMatchRequest");
Debug.Log("MatchMakingClient ListMatches :" + uri);
WWWForm wwwform = new WWWForm();
wwwform.AddField("version", Request.currentVersion);
wwwform.AddField("projectId", Application.cloudProjectId);
wwwform.AddField("sourceId", Utility.GetSourceID().ToString());
wwwform.AddField("accessTokenString", 0);
wwwform.AddField("domain", req.domain);
wwwform.AddField("pageSize", req.pageSize);
wwwform.AddField("pageNum", req.pageNum);
wwwform.AddField("nameFilter", req.nameFilter);
wwwform.AddField("filterOutPrivateMatches", req.filterOutPrivateMatches.ToString());
wwwform.AddField("eloScore", req.eloScore.ToString());
wwwform.headers["Accept"] = "application/json";
WWW www = new WWW(uri.ToString(), wwwform);
coroutine = base.StartCoroutine(this.ProcessMatchResponse<ListMatchResponse, NetworkMatch.DataResponseDelegate<List<MatchInfoSnapshot>>>(www, new NetworkMatch.InternalResponseDelegate<ListMatchResponse, NetworkMatch.DataResponseDelegate<List<MatchInfoSnapshot>>>(this.OnMatchList), callback));
}
return coroutine;
}
// Token: 0x06002EC4 RID: 11972 RVA: 0x000440F4 File Offset: 0x000422F4
internal void OnMatchList(ListMatchResponse response, NetworkMatch.DataResponseDelegate<List<MatchInfoSnapshot>> userCallback)
{
List<MatchInfoSnapshot> list = new List<MatchInfoSnapshot>();
foreach (MatchDesc matchDesc in response.matches)
{
list.Add(new MatchInfoSnapshot(matchDesc));
}
userCallback(response.success, response.extendedInfo, list);
}
// Token: 0x06002EC5 RID: 11973 RVA: 0x00044174 File Offset: 0x00042374
public Coroutine SetMatchAttributes(NetworkID networkId, bool isListed, int requestDomain, NetworkMatch.BasicResponseDelegate callback)
{
return this.SetMatchAttributes(new SetMatchAttributesRequest
{
networkId = networkId,
isListed = isListed,
domain = requestDomain
}, callback);
}
// Token: 0x06002EC6 RID: 11974 RVA: 0x000441B0 File Offset: 0x000423B0
internal Coroutine SetMatchAttributes(SetMatchAttributesRequest req, NetworkMatch.BasicResponseDelegate callback)
{
Coroutine coroutine;
if (callback == null)
{
Debug.Log("callback supplied is null, aborting SetMatchAttributes Request.");
coroutine = null;
}
else
{
Uri uri = new Uri(this.baseUri, "/json/reply/SetMatchAttributesRequest");
Debug.Log("MatchMakingClient SetMatchAttributes :" + uri);
WWWForm wwwform = new WWWForm();
wwwform.AddField("version", Request.currentVersion);
wwwform.AddField("projectId", Application.cloudProjectId);
wwwform.AddField("sourceId", Utility.GetSourceID().ToString());
wwwform.AddField("accessTokenString", Utility.GetAccessTokenForNetwork(req.networkId).GetByteString());
wwwform.AddField("domain", req.domain);
wwwform.AddField("networkId", req.networkId.ToString());
wwwform.AddField("isListed", req.isListed.ToString());
wwwform.headers["Accept"] = "application/json";
WWW www = new WWW(uri.ToString(), wwwform);
coroutine = base.StartCoroutine(this.ProcessMatchResponse<BasicResponse, NetworkMatch.BasicResponseDelegate>(www, new NetworkMatch.InternalResponseDelegate<BasicResponse, NetworkMatch.BasicResponseDelegate>(this.OnSetMatchAttributes), callback));
}
return coroutine;
}
// Token: 0x06002EC7 RID: 11975 RVA: 0x000442EC File Offset: 0x000424EC
internal void OnSetMatchAttributes(BasicResponse response, NetworkMatch.BasicResponseDelegate userCallback)
{
userCallback(response.success, response.extendedInfo);
}
// Token: 0x06002EC8 RID: 11976 RVA: 0x00044304 File Offset: 0x00042504
private IEnumerator ProcessMatchResponse<JSONRESPONSE, USERRESPONSEDELEGATETYPE>(WWW client, NetworkMatch.InternalResponseDelegate<JSONRESPONSE, USERRESPONSEDELEGATETYPE> internalCallback, USERRESPONSEDELEGATETYPE userCallback) where JSONRESPONSE : Response, new()
{
yield return client;
JSONRESPONSE jsonInterface = new JSONRESPONSE();
if (string.IsNullOrEmpty(client.error))
{
object obj;
if (global::SimpleJson.SimpleJson.TryDeserializeObject(client.text, out obj))
{
IDictionary<string, object> dictionary = obj as IDictionary<string, object>;
if (dictionary != null)
{
try
{
jsonInterface.Parse(obj);
}
catch (FormatException ex)
{
jsonInterface.SetFailure(UnityString.Format("FormatException:[{0}] ", new object[] { ex.ToString() }));
}
}
}
}
else
{
jsonInterface.SetFailure(UnityString.Format("Request error:[{0}] Raw response:[{1}]", new object[] { client.error, client.text }));
}
client.Dispose();
internalCallback(jsonInterface, userCallback);
yield break;
}
// Token: 0x04000918 RID: 2328
private Uri m_BaseUri = new Uri("https://mm.unet.unity3d.com");
// Token: 0x020002C2 RID: 706
// (Invoke) Token: 0x06002ECA RID: 11978
public delegate void BasicResponseDelegate(bool success, string extendedInfo);
// Token: 0x020002C3 RID: 707
// (Invoke) Token: 0x06002ECE RID: 11982
public delegate void DataResponseDelegate<T>(bool success, string extendedInfo, T responseData);
// Token: 0x020002C4 RID: 708
// (Invoke) Token: 0x06002ED2 RID: 11986
private delegate void InternalResponseDelegate<T, U>(T response, U userCallback);
}
}