Esempio n. 1
0
        //TODO: chagne all signitures
        public async UniTask MakeHostAsync(IpPortInfo ipPortInfo, GameUser user)
        {
            var serverUser = new ServerUserDTO
            {
                User       = user,
                IpPortInfo = ipPortInfo,
            };
            var serverUserJson = JsonConvert.SerializeObject(serverUser);
            var request        = UnityWebRequest.Post($"{BASE_ADDRESS}matches/makehost", "");

            request.uploadHandler             = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(serverUserJson));
            request.uploadHandler.contentType = "application/json";
            request.SetRequestHeader("Content-Type", "application/json");

            await request.SendWebRequest();
        }
Esempio n. 2
0
        //TODO: chagne all signitures
        public async UniTask <MatchJoinResultDTO> JoinMatchAsync(IpPortInfo ipPortInfo, string matchID, GameUser user)
        {
            var serverUser = new ServerUserDTO
            {
                User       = user,
                IpPortInfo = ipPortInfo,
            };
            var serverUserJson = JsonConvert.SerializeObject(serverUser);
            var request        = UnityWebRequest.Post($"{BASE_ADDRESS}matches/join?matchID={matchID}", "");

            request.uploadHandler             = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(serverUserJson));
            request.uploadHandler.contentType = "application/json";
            request.SetRequestHeader("Content-Type", "application/json");

            var response = await request.SendWebRequest();

            var matchJoinResultString = response.downloadHandler.text;

            return(JsonConvert.DeserializeObject <MatchJoinResultDTO>(matchJoinResultString));
        }