コード例 #1
0
ファイル: APIManager.cs プロジェクト: elleyerium/Elysium
        private static IEnumerator SendRequest(APIRequest request)
        {
            yield return(request.SendWebRequest());

            if (request.isNetworkError || request.isHttpError)
            {
                Debug.Log(request.error);
                Debug.Log(request.url);
            }
            else
            {
                APIResponse type;
                switch (request.APIRequestType)
                {
                case APIRequestType.Avatar:
                    type = request.Deserialize <Avatar>(request.downloadHandler.text);
                    break;

                case APIRequestType.Config:
                    type = request.Deserialize <Avatar>(request.downloadHandler.text);
                    break;

                case APIRequestType.Settings:
                    type = request.Deserialize <Avatar>(request.downloadHandler.text);
                    break;

                case APIRequestType.PlayerInfo:
                    type = request.Deserialize <PlayerInfo>(request.downloadHandler.text);
                    type = (PlayerInfo)type;
                    break;

                case APIRequestType.Leaderboards:
                    type = request.Deserialize <Leaderboards>(request.downloadHandler.text);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                Debug.Log(type.GetType().ToString());
                request.Dispose();
            }
        }