private void checkQueue() { StomtCreation stomtCreation = StomtOfflineQueue <StomtCreation> .pop(); if (stomtCreation != null) { Debug.Log("Send queued Stomt: " + stomtCreation); this.SendStomt(stomtCreation); return; } StomtSubscription stomtSubscription = StomtOfflineQueue <StomtSubscription> .pop(); if (stomtSubscription != null) { Debug.Log("Send queued Subscription: " + stomtSubscription); this.SendSubscription(stomtSubscription); return; } StomtTrack stomtTrack = StomtOfflineQueue <StomtTrack> .pop(); if (stomtTrack != null) { Debug.Log("Send queued Track: " + stomtTrack); this.SendTrack(stomtTrack); return; } }
public void SendTrack(StomtTrack track, Action <LitJsonStomt.JsonData> callbackSuccess = null, Action <HttpWebResponse> callbackError = null) { var url = string.Format("{0}/tracks", restServerURL); GetPOSTResponse(url, track.ToString(), callbackSuccess, callbackError, () => { StomtOfflineQueue <StomtTrack> .add(track); }); }
public static bool has() { if (!StomtOfflineQueue <T> .Loaded) { StomtOfflineQueue <T> .load(); } return(StomtOfflineQueue <T> .Queue.Count > 0); }
public static void add(T item) { if (!StomtOfflineQueue <T> .Loaded) { StomtOfflineQueue <T> .load(); } StomtOfflineQueue <T> .Queue.Add(item); StomtOfflineQueue <T> .save(); }
public void cleanConfig() { StomtConfig.Delete(); StomtOfflineQueue <StomtCreation> .clear(); StomtOfflineQueue <StomtSubscription> .clear(); StomtOfflineQueue <StomtTrack> .clear(); Debug.Log("Local config cleaned."); }
public static T pop() { if (!StomtOfflineQueue <T> .Loaded) { StomtOfflineQueue <T> .load(); } if (!StomtOfflineQueue <T> .has()) { return(default(T)); } T item = StomtOfflineQueue <T> .Queue[0]; StomtOfflineQueue <T> .Queue.Remove(item); StomtOfflineQueue <T> .save(); return(item); }
public void SendSubscription(StomtSubscription subscription, Action <LitJsonStomt.JsonData> callbackSuccess = null, Action <HttpWebResponse> callbackError = null) { var url = string.Format("{0}/authentication/subscribe", restServerURL); GetPOSTResponse(url, subscription.ToString(), (response) => { StomtConfig.Subscribed = true; var track = this.initStomtTrack(); track.event_category = "auth"; track.event_action = "subscribed"; this.SendTrack(track); if (callbackSuccess != null) { callbackSuccess(response); } }, callbackError, () => { // save and send later StomtOfflineQueue <StomtSubscription> .add(subscription); }); }
public static void clear() { StomtOfflineQueue <T> .Queue.Clear(); StomtOfflineQueue <T> .save(); }
public void SendStomt(StomtCreation stomtCreation, Action <LitJsonStomt.JsonData> callbackSuccess = null, Action <HttpWebResponse> callbackError = null) { // Upload file if pressent (and call function again) if (stomtCreation.screenshot != null) { SendImage(stomtCreation.screenshot, (response) => { var img_name = (string)response["images"]["stomt"]["name"]; stomtCreation.img_name = img_name; stomtCreation.screenshot = null; SendStomt(stomtCreation, callbackSuccess, callbackError); }, (response) => { // upload even when scrennshot upload failed stomtCreation.screenshot = null; SendStomt(stomtCreation, callbackSuccess, callbackError); }, () => { // save and send later StomtOfflineQueue <StomtCreation> .add(stomtCreation); }); return; } // Upload image if pressent (and call function again) if (stomtCreation.logs != null) { SendFile(stomtCreation.logs, (response) => { var file_uid = (string)response["files"]["stomt"]["file_uid"]; stomtCreation.file_uid = file_uid; stomtCreation.logs = null; SendStomt(stomtCreation, callbackSuccess, callbackError); }, (response) => { // upload even when logs upload failed stomtCreation.logs = null; SendStomt(stomtCreation, callbackSuccess, callbackError); }, () => { // save and send later StomtOfflineQueue <StomtCreation> .add(stomtCreation); }); return; } // Submit stomt var url = string.Format("{0}/stomts", restServerURL); // Send Stomt GetPOSTResponse(url, stomtCreation.ToString(), (response) => { string stomt_id = (string)response["id"]; var track = this.initStomtTrack(); track.event_category = "stomt"; track.event_action = "submit"; track.stomt_id = stomt_id; this.SendTrack(track); if (callbackSuccess != null) { callbackSuccess(response); } }, callbackError, () => { // save and send later StomtOfflineQueue <StomtCreation> .add(stomtCreation); }); }