private void _ConnectedToServer(UpdatesResponse response) { if (_isOff) { return; } try { _request = null; if (response == null) { Debug.WriteLine("LongPollServer got successful response, but it is NULL"); } else { _info.Ts = response.Ts; _SaveInfo(); if (response.Updates != null && response.Updates.Count > 0) { App.Current.UpdatesService.PutUpdates(response.Updates); } } _RefreshUpdates(); } catch (Exception ex) { Debug.WriteLine("_ConnectedToServer failed: " + ex.Message + Environment.NewLine + ex.StackTrace); } }
private void LogReceivedUpdates(UpdatesResponse updatesResponse) { StringBuilder stringBuilder = new StringBuilder("Received the following updates:" + Environment.NewLine); foreach (LongPollServerUpdateData update in updatesResponse.Updates) { stringBuilder = stringBuilder.Append(update.ToString() + Environment.NewLine); } }
public async Task GetUpdate() { if (_isUpdating) { return; } try { _isUpdating = true; UpdatesRequest request = new UpdatesRequest(); request.LastActivityDate = LastActivity; UpdatesResponse response = await request.GetUpdate().ConfigureAwait(false); if (response.Matches != null && response.Matches.Length > 0) { foreach (Match match in response.Matches) { _matches.Add(match); } } LastActivity = DateTime.Parse(response.LastActivityDate); } catch (HttpRequestException e) { //if (e.Message.Contains("Unauthorized")) //{ // (Application.Current as IApp).Logout(); //} } catch (Exception ex) { Console.WriteLine("Exception during update: " + ex.Message); } finally { _isUpdating = false; } }
private void _ParseResponse(string response) { try { if (response == null || response.Contains("failed")) { // TODO Get actual code _failHandler(2); } else { // Ok UpdatesResponse updates = SerializeHelper.Deserialise <UpdatesResponse>(response); _successHandler(updates); } } catch (Exception ex) { Debug.WriteLine("Parse response from LongPollServerRequest failed." + ex.Message + "\n" + ex.StackTrace); _failHandler(1); } }