Exemple #1
0
        internal Coroutine ListMatches(ListMatchRequest req, DataResponseDelegate <List <MatchInfoSnapshot> > callback)
        {
            if (callback == null)
            {
                UnityEngine.Debug.Log("callback supplied is null, aborting ListMatch Request.");
                return(null);
            }
            Uri uri = new Uri(this.baseUri, "/json/reply/ListMatchRequest");

            UnityEngine.Debug.Log("MatchMakingClient ListMatches :" + uri);
            WWWForm form = new WWWForm();

            form.AddField("version", Request.currentVersion);
            form.AddField("projectId", Application.cloudProjectId);
            form.AddField("sourceId", Utility.GetSourceID().ToString());
            form.AddField("accessTokenString", 0);
            form.AddField("domain", req.domain);
            form.AddField("pageSize", req.pageSize);
            form.AddField("pageNum", req.pageNum);
            form.AddField("nameFilter", req.nameFilter);
            form.AddField("filterOutPrivateMatches", req.filterOutPrivateMatches.ToString());
            form.AddField("eloScore", req.eloScore.ToString());
            form.headers["Accept"] = "application/json";
            WWW client = new WWW(uri.ToString(), form);

            return(base.StartCoroutine(this.ProcessMatchResponse <ListMatchResponse, DataResponseDelegate <List <MatchInfoSnapshot> > >(client, new InternalResponseDelegate <ListMatchResponse, DataResponseDelegate <List <MatchInfoSnapshot> > >(this.OnMatchList), callback)));
        }
Exemple #2
0
        // Start getting a list of matches
        internal Coroutine ListMatches(ListMatchRequest req, DataResponseDelegate <List <MatchInfoSnapshot> > callback)
        {
            if (callback == null)
            {
                Debug.Log("callback supplied is null, aborting ListMatch Request.");
                return(null);
            }

            Uri uri = new Uri(baseUri, "/json/reply/ListMatchRequest");

            Debug.Log("MatchMakingClient ListMatches :" + uri);

            var data = new WWWForm();

            data.AddField("version", UnityEngine.Networking.Match.Request.currentVersion);
            data.AddField("projectId", Application.cloudProjectId);
            data.AddField("sourceId", Utility.GetSourceID().ToString());
            data.AddField("accessTokenString", 0); // Set access token to 0 for list requests
            data.AddField("domain", req.domain);

            data.AddField("pageSize", req.pageSize);
            data.AddField("pageNum", req.pageNum);
            data.AddField("nameFilter", req.nameFilter);
            data.AddField("filterOutPrivateMatches", req.filterOutPrivateMatches.ToString());
            data.AddField("eloScore", req.eloScore.ToString());

            data.headers["Accept"] = "application/json";

            var client = UnityWebRequest.Post(uri.ToString(), data);

            return(StartCoroutine(ProcessMatchResponse <ListMatchResponse, DataResponseDelegate <List <MatchInfoSnapshot> > >(client, OnMatchList, callback)));
        }
Exemple #3
0
        // Begin joining a match
        internal Coroutine JoinMatch(JoinMatchRequest req, DataResponseDelegate <MatchInfo> callback)
        {
            if (callback == null)
            {
                Debug.Log("callback supplied is null, aborting JoinMatch Request.");
                return(null);
            }

            Uri uri = new Uri(baseUri, "/json/reply/JoinMatchRequest");

            Debug.Log("MatchMakingClient Join :" + uri);

            var data = new WWWForm();

            data.AddField("version", UnityEngine.Networking.Match.Request.currentVersion);
            data.AddField("projectId", Application.cloudProjectId);
            data.AddField("sourceId", Utility.GetSourceID().ToString());
            data.AddField("accessTokenString", 0);
            data.AddField("domain", req.domain);

            data.AddField("networkId", req.networkId.ToString());
            data.AddField("password", req.password);
            data.AddField("publicAddress", req.publicAddress);
            data.AddField("privateAddress", req.privateAddress);
            data.AddField("eloScore", req.eloScore.ToString());

            data.headers["Accept"] = "application/json";

            var client = UnityWebRequest.Post(uri.ToString(), data);

            return(StartCoroutine(ProcessMatchResponse <JoinMatchResponse, DataResponseDelegate <MatchInfo> >(client, OnMatchJoined, callback)));
        }
Exemple #4
0
        internal Coroutine CreateMatch(CreateMatchRequest req, DataResponseDelegate <MatchInfo> callback)
        {
            if (callback == null)
            {
                Debug.Log("callback supplied is null, aborting CreateMatch Request.");
                return(null);
            }
            Uri uri = new Uri(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 client = new WWW(uri.ToString(), wWWForm);

            return(StartCoroutine(ProcessMatchResponse <CreateMatchResponse, DataResponseDelegate <MatchInfo> >(client, OnMatchCreate, callback)));
        }
Exemple #5
0
        internal Coroutine JoinMatch(JoinMatchRequest req, DataResponseDelegate <MatchInfo> callback)
        {
            if (callback == null)
            {
                UnityEngine.Debug.Log("callback supplied is null, aborting JoinMatch Request.");
                return(null);
            }
            Uri uri = new Uri(this.baseUri, "/json/reply/JoinMatchRequest");

            UnityEngine.Debug.Log("MatchMakingClient Join :" + uri);
            WWWForm form = new WWWForm();

            form.AddField("version", Request.currentVersion);
            form.AddField("projectId", Application.cloudProjectId);
            form.AddField("sourceId", Utility.GetSourceID().ToString());
            form.AddField("accessTokenString", 0);
            form.AddField("domain", req.domain);
            form.AddField("networkId", req.networkId.ToString());
            form.AddField("password", req.password);
            form.AddField("publicAddress", req.publicAddress);
            form.AddField("privateAddress", req.privateAddress);
            form.AddField("eloScore", req.eloScore.ToString());
            form.headers["Accept"] = "application/json";
            WWW client = new WWW(uri.ToString(), form);

            return(base.StartCoroutine(this.ProcessMatchResponse <JoinMatchResponse, DataResponseDelegate <MatchInfo> >(client, new InternalResponseDelegate <JoinMatchResponse, DataResponseDelegate <MatchInfo> >(this.OnMatchJoined), callback)));
        }
Exemple #6
0
 internal virtual void OnMatchCreate(CreateMatchResponse response, DataResponseDelegate <MatchInfo> userCallback)
 {
     if (response.success)
     {
         Utility.SetAccessTokenForNetwork(response.networkId, new NetworkAccessToken(response.accessTokenString));
     }
     userCallback(response.success, response.extendedInfo, new MatchInfo(response));
 }
Exemple #7
0
        internal void OnMatchList(ListMatchResponse response, DataResponseDelegate <List <MatchInfoSnapshot> > userCallback)
        {
            List <MatchInfoSnapshot> list = new List <MatchInfoSnapshot>();

            foreach (MatchDesc match in response.matches)
            {
                list.Add(new MatchInfoSnapshot(match));
            }
            userCallback(response.success, response.extendedInfo, list);
        }
Exemple #8
0
        internal void OnMatchList(ListMatchResponse response, DataResponseDelegate <List <MatchInfoSnapshot> > userCallback)
        {
            List <MatchInfoSnapshot> responseData = new List <MatchInfoSnapshot>();

            foreach (MatchDesc desc in response.matches)
            {
                responseData.Add(new MatchInfoSnapshot(desc));
            }
            userCallback(response.success, response.extendedInfo, responseData);
        }
Exemple #9
0
 public Coroutine ListMatches(int startPageNumber, int resultPageSize, string matchNameFilter, bool filterOutPrivateMatchesFromResults, int eloScoreTarget, int requestDomain, DataResponseDelegate <List <MatchInfoSnapshot> > callback)
 {
     if (UnityEngine.Application.platform == RuntimePlatform.WebGLPlayer)
     {
         Debug.LogError("Matchmaking is not supported on WebGL player.");
         return(null);
     }
     else
     {
         return(ListMatches(new ListMatchRequest {
             pageNum = startPageNumber, pageSize = resultPageSize, nameFilter = matchNameFilter, filterOutPrivateMatches = filterOutPrivateMatchesFromResults, eloScore = eloScoreTarget, domain = requestDomain
         }, callback));
     }
 }
Exemple #10
0
 public Coroutine JoinMatch(NetworkID netId, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForClient, int requestDomain, DataResponseDelegate <MatchInfo> callback)
 {
     return(JoinMatch(new JoinMatchRequest {
         networkId = netId, password = matchPassword, publicAddress = publicClientAddress, privateAddress = privateClientAddress, eloScore = eloScoreForClient, domain = requestDomain
     }, callback));
 }
Exemple #11
0
 public Coroutine CreateMatch(string matchName, uint matchSize, bool matchAdvertise, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForMatch, int requestDomain, DataResponseDelegate <MatchInfo> callback)
 {
     if (UnityEngine.Application.platform == RuntimePlatform.WebGLPlayer)
     {
         Debug.LogError("Matchmaking is not supported on WebGL player.");
         return(null);
     }
     return(CreateMatch(new CreateMatchRequest {
         name = matchName, size = matchSize, advertise = matchAdvertise, password = matchPassword, publicAddress = publicClientAddress, privateAddress = privateClientAddress, eloScore = eloScoreForMatch, domain = requestDomain
     }, callback));
 }
Exemple #12
0
        public Coroutine CreateMatch(string matchName, uint matchSize, bool matchAdvertise, string matchPassword, string publicClientAddress, string privateClientAddress, int eloScoreForMatch, int requestDomain, DataResponseDelegate <MatchInfo> callback)
        {
            CreateMatchRequest req = new CreateMatchRequest {
                name           = matchName,
                size           = matchSize,
                advertise      = matchAdvertise,
                password       = matchPassword,
                publicAddress  = publicClientAddress,
                privateAddress = privateClientAddress,
                eloScore       = eloScoreForMatch,
                domain         = requestDomain
            };

            return(this.CreateMatch(req, callback));
        }
Exemple #13
0
        public Coroutine ListMatches(int startPageNumber, int resultPageSize, string matchNameFilter, bool filterOutPrivateMatchesFromResults, int eloScoreTarget, int requestDomain, DataResponseDelegate <List <MatchInfoSnapshot> > callback)
        {
            ListMatchRequest req = new ListMatchRequest {
                pageNum    = startPageNumber,
                pageSize   = resultPageSize,
                nameFilter = matchNameFilter,
                filterOutPrivateMatches = filterOutPrivateMatchesFromResults,
                eloScore = eloScoreTarget,
                domain   = requestDomain
            };

            return(this.ListMatches(req, callback));
        }