RCNConfigRealtime.swift 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import Foundation
  2. class RCNConfigRealtime: NSObject {
  3. private var _listeners: NSMutableSet<AnyHashable>
  4. private var _realtimeLockQueue: DispatchQueue
  5. private var _notificationCenter: NotificationCenter
  6. var session: URLSession?
  7. var dataTask: URLSessionDataTask?
  8. var request: NSMutableURLRequest?
  9. private var configFetch: RCNConfigFetch
  10. private var settings: RCNConfigSettings
  11. private var options: FIROptions
  12. private var namespace: String
  13. private var remainingRetryCount : Int = 0
  14. private var isRequestInProgress : Bool = false
  15. private var isInBackground : Bool = false
  16. private var isRealtimeDisabled : Bool = false
  17. init(configFetch: RCNConfigFetch, settings: RCNConfigSettings, namespace: String, options: FIROptions) {
  18. _listeners = NSMutableSet<AnyHashable>()
  19. _realtimeLockQueue = RCNConfigRealtime.realtimeRemoteConfigSerialQueue()
  20. _notificationCenter = NotificationCenter.default
  21. self.configFetch = configFetch
  22. self.settings = settings
  23. self.options = options
  24. self.namespace = namespace
  25. _remainingRetryCount = max(RCNConstants.gMaxRetries - (settings.realtimeRetryCount), 1)
  26. _isRequestInProgress = false;
  27. _isRealtimeDisabled = false;
  28. _isInBackground = false;
  29. setUpHttpRequest()
  30. setUpHttpSession()
  31. backgroundChangeListener()
  32. }
  33. static func realtimeRemoteConfigSerialQueue() -> DispatchQueue {
  34. return DispatchQueue(label: RCNConstants.RCNRemoteConfigQueueLabel)
  35. }
  36. func propagateErrors(error: Error) {
  37. }
  38. func retryHTTPConnection() {
  39. }
  40. func addConfigUpdateListener(listener: @escaping (_ update: FIRRemoteConfigUpdate?, _ error: NSError?) -> Void ) -> FIRConfigUpdateListenerRegistration? {
  41. return nil
  42. }
  43. func removeConfigUpdateListener(listener: @escaping (_ update: FIRRemoteConfigUpdate?, _ error: NSError?) -> Void) {
  44. }
  45. func beginRealtimeStream() {
  46. }
  47. func pauseRealtimeStream() {
  48. }
  49. func URLSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
  50. }
  51. func URLSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceiveResponse: URLResponse,
  52. completionHandler: @escaping (URLSessionResponseDisposition) -> Void) {
  53. }
  54. func URLSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
  55. }
  56. func evaluateStreamResponse(response: [AnyHashable : Any], error: NSError?) {
  57. }
  58. }