Example #1
0
 // レスポンスの処理
 public void CheckAndComplite(Util.Future <T> result, Action <T> onComplete = null)
 {
     if (Check(result))
     {
         Complete(result.Result, onComplete);
     }
 }
Example #2
0
            // エラーチェック
            public bool Check(Util.Future <T> result)
            {
                this.InRetrieving = false;

                if (result.HasException)
                {
                    var httpexception = result.Exception as Api.Net.HTTPException;
                    int statuscode    = 0;

                    if (httpexception != null && httpexception.Response != null)
                    {
                        statuscode = httpexception.Response.StatusCode;
                    }

                    string msg = "";

                    switch (statuscode)
                    {
                    case 404:
                        msg = "通信エラーです。";
                        break;

                    case 426:
                        // msg = "APIバージョンが違います。";
                        msg = "新しいバージョンがあります。\nアプリをアップデートしてください。";
                        break;

                    case 502:
                    case 503:
                        msg = "サーバーメンテナンス中です。\nしばらくしてからアクセスしてください。";
                        break;

                    case 500:
                        msg = "Internal Server Error\n" + result.Exception.Message;
                        break;

                    case 0:                                                    // マスターデータに相違がある場合、bootのレスポンスの処理で例外がthrowされる
                        msg = "ゲームサーバーに接続できません。\n" + result.Exception.Message; // "マスターデータが違います。";
                        break;

                    default:
                        msg = "ゲームサーバーに接続できません。" + statuscode.ToString();
                        break;
                    }

                    if (GameServer.OnFatalError != null)
                    {
                        GameServer.OnFatalError(msg, statuscode);
                    }
                    else
                    {
                        Debug.LogError(string.Format("Network Error {0}: {1}", statuscode, msg));
                    }

                    return(false);
                }

                return(true);
            }