FSTStream.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
  18. @class FSTMutationResult;
  19. @class FSTWatchChange;
  20. NS_ASSUME_NONNULL_BEGIN
  21. #pragma mark - FSTWatchStreamDelegate
  22. /** A protocol defining the events that can be emitted by the FSTWatchStream. */
  23. @protocol FSTWatchStreamDelegate <NSObject>
  24. /** Called by the FSTWatchStream when it is ready to accept outbound request messages. */
  25. - (void)watchStreamDidOpen;
  26. /**
  27. * Called by the FSTWatchStream with changes and the snapshot versions included in in the
  28. * WatchChange responses sent back by the server.
  29. */
  30. - (void)watchStreamDidChange:(FSTWatchChange *)change
  31. snapshotVersion:(const firebase::firestore::model::SnapshotVersion &)snapshotVersion;
  32. /**
  33. * Called by the FSTWatchStream when the underlying streaming RPC is interrupted for whatever
  34. * reason, usually because of an error, but possibly due to an idle timeout. The error passed to
  35. * this method may be nil, in which case the stream was closed without attributable fault.
  36. *
  37. * NOTE: This will not be called after `stop` is called on the stream. See "Starting and Stopping"
  38. * on FSTStream for details.
  39. */
  40. - (void)watchStreamWasInterruptedWithError:(nullable NSError *)error;
  41. @end
  42. #pragma mark - FSTWriteStreamDelegate
  43. @protocol FSTWriteStreamDelegate <NSObject>
  44. /** Called by the FSTWriteStream when it is ready to accept outbound request messages. */
  45. - (void)writeStreamDidOpen;
  46. /**
  47. * Called by the FSTWriteStream upon a successful handshake response from the server, which is the
  48. * receiver's cue to send any pending writes.
  49. */
  50. - (void)writeStreamDidCompleteHandshake;
  51. /**
  52. * Called by the FSTWriteStream upon receiving a StreamingWriteResponse from the server that
  53. * contains mutation results.
  54. */
  55. - (void)writeStreamDidReceiveResponseWithVersion:
  56. (const firebase::firestore::model::SnapshotVersion &)commitVersion
  57. mutationResults:(NSArray<FSTMutationResult *> *)results;
  58. /**
  59. * Called when the FSTWriteStream's underlying RPC is interrupted for whatever reason, usually
  60. * because of an error, but possibly due to an idle timeout. The error passed to this method may be
  61. * nil, in which case the stream was closed without attributable fault.
  62. *
  63. * NOTE: This will not be called after `stop` is called on the stream. See "Starting and Stopping"
  64. * on FSTStream for details.
  65. */
  66. - (void)writeStreamWasInterruptedWithError:(nullable NSError *)error;
  67. @end
  68. NS_ASSUME_NONNULL_END