Esempio n. 1
0
        /// <summary>
        /// インスタレーション情報をNebulaサーバから取得する
        /// </summary>
        /// <returns>NbSsePushInstallation</returns>
        /// <exception cref="InvalidOperationException">インスタレーションのパラメータ未設定、インスタレーション情報の保存・削除失敗</exception>
        /// <exception cref="NbHttpException">リクエスト送信失敗</exception>
        public static async Task <NbSsePushInstallation> RefreshCurrentInstallation()
        {
            NbSsePushInstallation installation = NbSsePushInstallation.GetCurrentInstallation();

            NbUtil.NotNullWithInvalidOperation(installation.InstallationId, "Null installationId");

            try
            {
                // リクエスト生成&送信
                var json = await installation.SendRequestForRefresh();

                // ストレージに保存
                installation.SaveAndLoad(json);
            }
            catch (NbHttpException e)
            {
                // 該当するインスタレーションが存在しない場合
                if (e.StatusCode == HttpStatusCode.NotFound)
                {
                    // ストレージ内のインスタレーション情報を削除
                    installation.DeleteAndLoad();
                }
                throw e;
            }
            return(installation);
        }