protected static void SendRequest(string point, JsonObject args, System.Action <JsonObject> success, System.Action <string> failed) { var argsBytes = System.Text.Encoding.UTF8.GetBytes(GoWMiniJSON.Serialize(args)); var request = WebRequest.Create(Settings.serverUrl + "/" + point); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = argsBytes.Length; var dataStream = request.GetRequestStream(); dataStream.Write(argsBytes, 0, argsBytes.Length); dataStream.Close(); try { var response = request.GetResponse(); webErrorLine = null; if (success != null) { success((JsonObject)GoWMiniJSON.Deserialize(GetTextResponse(response))); } } catch (WebException e) { var errorResponse = (JsonObject)GoWMiniJSON.Deserialize(GetTextResponse(e.Response)); webErrorLine = errorResponse["error"].ToString(); if (failed != null) { failed(webErrorLine); } LogUtils.LogError(webErrorLine); } }
private void SaveData() { PlayerPrefs.SetString(GOW_DATA, GoWMiniJSON.Serialize(_gowData)); PlayerPrefs.Save(); }
protected void OnCurrentNotificationRecieved(JsonObject notification) { if (!GowNotification.IsValid(notification)) { LogUtils.LogWarning("Not valid json : " + (notification == null ? "<NULL>" : GOWMiniJSON.Serialize(notification))); return; } if (CurrentNotificationRecieved != null) { CurrentNotificationRecieved(new GowNotification(notification)); } }
protected void OnNotificationsRecieved(JsonObject[] notifications) { if (NotificationRecieved != null) { NotificationRecieved(notifications.Select(json => { if (!GowNotification.IsValid(json)) { LogUtils.LogWarning("Not valid json : " + json == null ? "<NULL>" : GOWMiniJSON.Serialize(json)); return(null); } return(new GowNotification(json)); }).SelectNotNull().ToArray()); } }