/// <summary> /// セッショントークン有効稼働かの処理を行う /// </summary> internal void _checkInvalidSessionToken(string code) { if (NCMBException.INCORRECT_HEADER.Equals(code)) { if ((this._sessionToken != null) && (this._sessionToken.Equals(NCMBUser._getCurrentSessionToken()))) { NCMBUser._logOutEvent(); } NCMBDebug.Log("CurrentUser is found, sessionToken info error, delete localdata"); } }
/// <summary> /// リクエストの生成を行う /// </summary> private HttpWebRequest _returnRequest() { //URLをエンコード var uri = new Uri(_url); _url = uri.AbsoluteUri; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(_url); //デフォルトの生成 _makeTimeStamp(); //タイムスタンプの生成 req.Timeout = REQUEST_TIME_OUT; StringBuilder stringHashData = _makeSignatureHashData(); string result = _makeSignature(stringHashData.ToString()); //シグネチャ生成 //ヘッダー設定 //メソッド追加 switch (_method) { case ConnectType.POST: req.Method = "POST"; break; case ConnectType.PUT: req.Method = "PUT"; break; case ConnectType.GET: req.Method = "GET"; break; case ConnectType.DELETE: req.Method = "DELETE"; break; } req.ContentType = "application/json"; req.Headers.Add(HEADER_APPLICATION_KEY, _applicationKey); req.Headers.Add(HEADER_SIGNATURE, result); req.Headers.Add(HEADER_TIMESTAMP_KEY, _headerTimestamp); if ((_sessionToken != null) && (_sessionToken != "")) { req.Headers.Add(HEADER_SESSION_TOKEN, _sessionToken); NCMBDebug.Log("Session token :" + _sessionToken); } req.Headers.Add(HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*"); return(req); }
/// <summary> /// リクエストの生成を行う /// </summary> internal UnityWebRequest _returnRequest() { //URLをエンコード var uri = new Uri(_url); _url = uri.AbsoluteUri; //メソッド追加 String method = ""; switch (_method) { case ConnectType.POST: method = "POST"; break; case ConnectType.PUT: method = "PUT"; break; case ConnectType.GET: method = "GET"; break; case ConnectType.DELETE: method = "DELETE"; break; } UnityWebRequest req = new UnityWebRequest(_url, method); _makeTimeStamp(); //タイムスタンプの生成 StringBuilder stringHashData = _makeSignatureHashData(); string result = _makeSignature(stringHashData.ToString()); //シグネチャ生成 // ContentType設定 if (req.method.Equals("POST") && _file != null || req.method.Equals("PUT") && _file != null) { req.SetRequestHeader("Content-Type", "multipart/form-data; boundary=_NCMBBoundary"); } else { req.SetRequestHeader("Content-Type", "application/json"); } //ヘッダー設定 req.SetRequestHeader(HEADER_APPLICATION_KEY, _applicationKey); req.SetRequestHeader(HEADER_SIGNATURE, result); req.SetRequestHeader(HEADER_TIMESTAMP_KEY, _headerTimestamp); req.SetRequestHeader(HEADER_USER_AGENT_KEY, HEADER_USER_AGENT_VALUE); if ((_sessionToken != null) && (_sessionToken != "")) { req.SetRequestHeader(HEADER_SESSION_TOKEN, _sessionToken); NCMBDebug.Log("Session token :" + _sessionToken); } //req.SetRequestHeader (HEADER_ACCESS_CONTROL_ALLOW_ORIGIN, "*"); if (_content != null && req.GetRequestHeader("Content-Type").Equals("multipart/form-data; boundary=_NCMBBoundary")) { _setUploadHandlerForFile(req); } else if (_content != null) { byte[] bodyRaw = Encoding.UTF8.GetBytes(_content); req.uploadHandler = (UploadHandler) new UploadHandlerRaw(bodyRaw); } req.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); return(req); }