private void _GetUpdates() { if (_isOff) return; try { _request = new LongPollServerRequest(_info.Server, _info.Key, _info.Ts, Modes.DontGetAttachments, _ConnectedToServer, _ConnectionFailed); _request.Execute(); } catch (ArgumentNullException) { _RefreshServerInfo(); } catch (Exception ex) { Debug.WriteLine("_GetUpdates failed: " + ex.Message); _RefreshServerInfoAfterTimeOut(); } }
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 _ConnectionFailed(int errorCode) { _request = null; if (errorCode == 2) { // Need to update server info and reconnect _RefreshServerInfo(); } else { Debug.WriteLine("LongPollServer can't get updates because of strange error with code " + errorCode.ToString() + ", but expected 2"); _RefreshUpdates(); } }