public override void Send(Action <string> success, Action <string> fail) { JulietLogger.Info(TAG, "Send"); Dictionary <string, string> content = new Dictionary <string, string> { { this.usernameKey, this.usernameValue }, { this.passwordKey, this.passwordValue } }; foreach (var attribute in attributes) { string key = attribute.Key; string value = (string)attribute.Value; content.Add(key, value); } MethodForm form = new MethodForm() { Method = this.methodType, URL = this.url, POSTLOGIN = content }; JulietAPI.Instance.Request(form, success, fail); }
public override ICommonRequest SetEventAttribute(string key, object value) { this.attributes.Add(key, value); JulietLogger.Info(TAG, "Key " + key + ", Value " + value); return(this); }
public override ITextureRequest SetURL(string url) { this.url = url; JulietLogger.Info(TAG, "Url " + this.url); return(this); }
public override ICommonRequest SetEventImageAttribute(string key, ImageType values) { this.attributeImages.Add(key, values); JulietLogger.Info(TAG, "Key " + key + ", Filename " + values.filename + ", MineType " + values.mineType + ", Size " + values.imgBytes.Length); return(this); }
public override ILoginRequest SetPassword(string key, string value) { this.passwordKey = key; this.passwordValue = value; JulietLogger.Info(TAG, "SetPassword " + this.passwordKey + ", " + this.passwordValue); return(this); }
public override ILoginRequest SetUsername(string key, string value) { this.usernameKey = key; this.usernameValue = value; JulietLogger.Info(TAG, "SetUsername " + this.usernameKey + ", " + this.usernameValue); return(this); }
public override ICommonRequest SetURL(string url, MethodType methodType = MethodType.GET) { this.url = url; this.methodType = methodType; JulietLogger.Info(TAG, "Url " + this.url); JulietLogger.Info(TAG, "MethodType " + this.methodType); return(this); }
public Juliet() { JulietLogger.Info(TAG, "Create Juliet API"); // Create instance to use API GameObject api = new GameObject(API_JULIET); api.AddComponent <JulietAPI>(); api.name = API_JULIET; }
public override void Send(Action <Texture> success, Action <string> fail) { JulietLogger.Info(TAG, "Send"); MethodForm form = new MethodForm() { URL = this.url }; JulietAPI.Instance.Request(form, success, fail); }
public override ICommonRequest SetURL(string url, MethodType methodType = MethodType.GET, params object[] param) { this.url = url; JulietLogger.Info(TAG, "Url " + this.url); this.url = SetURLFormat(url, param); this.methodType = methodType; JulietLogger.Info(TAG, "Url format " + this.url); JulietLogger.Info(TAG, "MethodType " + this.methodType); return(this); }
public override void SendWithImage(Action <string> success, Action <string> fail) { JulietLogger.Info(TAG, "Send "); MethodForm form = new MethodForm() { Method = MethodType.POST, URL = this.url }; WWWForm contentPost = new WWWForm(); foreach (var attribute in attributes) { string key = attribute.Key; string value = attribute.Value.ToString(); JulietLogger.Info(TAG, "SendWithImage Key " + key + ", Value " + value); contentPost.AddField(key, value); } foreach (var attribute in attributeImages) { string key = attribute.Key; ImageType value = attribute.Value; JulietLogger.Info(TAG, "SendWithImage Key " + key + ", Filename " + value.filename + ", MineType " + value.mineType + ", Size " + value.imgBytes.Length); contentPost.AddBinaryData(key, value.imgBytes, value.filename, value.mineType); } form.POST_IMAGES = contentPost; JulietAPI.Instance.Request(form, success, fail); }
public IEnumerator Connecting(MethodForm methodForm, Action <string> successCallback, Action <string> failCallback) { JulietLogger.Info(TAG, "Connecting to ... " + methodForm.WebRequest.url); using (UnityWebRequest www = methodForm.WebRequest) { JulietLogger.Info(TAG, "Wating for Response ... "); yield return(www.SendWebRequest()); try { JulietLogger.Info(TAG, "Responsed from Server ... "); if (!www.isNetworkError) { long code = www.responseCode; JulietLogger.Info(TAG, "Http Status Code " + code); switch (code) { case 200: JulietLogger.Info(TAG, "Successed Responsed ... " + www.downloadHandler.text); successCallback(www.downloadHandler.text); break; default: string errorFormat = "{ \"Status\":" + code + ", \"Message\": \"" + www.error + " \"}"; JulietLogger.Info(TAG, "Failed Responsed ... " + errorFormat); failCallback(errorFormat); break; } } else { string errorFormat = "{ \"Status\":" + 500 + ", \"Message\": \"" + www.error + " \"}"; JulietLogger.Info(TAG, "Internal Server Failed Responsed ... " + errorFormat); failCallback(errorFormat); } } catch (WebException ex) { JulietLogger.Info(TAG, "Error Web Exception " + ex.Message); string errorFormat = ""; if (ex.Status == WebExceptionStatus.ProtocolError) { if (ex.Response is HttpWebResponse response) { errorFormat = "{ \"Status\":" + (int)response.StatusCode + ", \"Message\": \"" + www.error + " \"}"; failCallback(errorFormat); } else { errorFormat = "{ \"Status\":" + 400 + ", \"Message\": \"" + www.error + " \"}"; } } else { errorFormat = "{ \"Status\":" + 400 + ", \"Message\": \"" + www.error + " \"}"; } failCallback(errorFormat); } catch (Exception ex) { JulietLogger.Info(TAG, "Error Web Exception " + ex.Message); string errorFormat = "{ \"Status\":" + 400 + ", \"Message\": \"" + www.error + " \"}"; failCallback(errorFormat); } } }
public IEnumerator Connecting(MethodForm methodForm, Action <Texture> successCallback, Action <string> failCallback) { JulietLogger.Info(TAG, "Connecting to ... " + methodForm.URL); Uri uri = new Uri(methodForm.URL); UnityWebRequest www = UnityWebRequestTexture.GetTexture(uri); yield return(www.SendWebRequest()); try { if (www.isNetworkError || www.isHttpError) { string errorFormat = string.Format(JulietShareVariable.FORMAT_ERROR, www.responseCode, www.error); JulietLogger.Info(TAG, "Failed Responsed ... " + errorFormat); failCallback(errorFormat); } else { JulietLogger.Info(TAG, "Successed Responsed"); Texture texture = ((DownloadHandlerTexture)www.downloadHandler).texture; successCallback(texture); } } catch (WebException ex) { JulietLogger.Info(TAG, "Error Web Exception " + ex.Message); string errorFormat = ""; if (ex.Status == WebExceptionStatus.ProtocolError) { if (ex.Response is HttpWebResponse response) { errorFormat = "{ \"Status\":" + (int)response.StatusCode + ", \"Message\": \"" + www.error + " \"}"; failCallback(errorFormat); } else { errorFormat = "{ \"Status\":" + 400 + ", \"Message\": \"" + www.error + " \"}"; } } else { errorFormat = "{ \"Status\":" + 400 + ", \"Message\": \"" + www.error + " \"}"; } failCallback(errorFormat); } catch (Exception ex) { JulietLogger.Info(TAG, "Error Web Exception " + ex.Message); string errorFormat = "{ \"Status\":" + 400 + ", \"Message\": \"" + www.error + " \"}"; failCallback(errorFormat); } }
private void OnLoadTexture(Texture result) { JulietLogger.Info(TAG, result.name); }
private void OnRequestFailed(string result) { JulietLogger.Info(TAG, result); }
private void OnLoadCharacter(string result) { JulietLogger.Info(TAG, result); }
private void OnLoginFailed(string result) { JulietLogger.Info(TAG, result); }
public ILoginRequest Login() { JulietLogger.Info(TAG, "Initial Login"); return(new LoginRequest()); }
public ITextureRequest Texture() { JulietLogger.Info(TAG, "Initial Texture"); return(new TextureRequest()); }
public ICommonRequest Common() { JulietLogger.Info(TAG, "Initial Common"); return(new CommonRequest()); }
public override void Send(Action <string> success, Action <string> fail) { JulietLogger.Info(TAG, "Send "); MethodForm form = new MethodForm() { Method = this.methodType, URL = this.url }; switch (this.methodType) { case MethodType.POST: Dictionary <string, string> contentPost = new Dictionary <string, string>(); foreach (var attribute in attributes) { string key = attribute.Key; string value = (string)attribute.Value; contentPost.Add(key, value); } form.POST = contentPost; break; case MethodType.GET: form.GET = this.url; break; case MethodType.PUT: Dictionary <string, string> contentPut = new Dictionary <string, string>(); foreach (var attribute in attributes) { string key = attribute.Key; string value = (string)attribute.Value; contentPut.Add(key, value); } string jsonPut = JsonUtility.ToJson(contentPut); form.PUT = System.Text.Encoding.UTF8.GetBytes(jsonPut); break; case MethodType.DELETE: form.DELETE = this.url; break; } JulietAPI.Instance.Request(form, success, fail); }