FSTStream.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. #include "Firestore/core/src/firebase/firestore/util/status.h"
  19. @class FSTMutationResult;
  20. @class FSTWatchChange;
  21. NS_ASSUME_NONNULL_BEGIN
  22. #pragma mark - FSTWatchStreamDelegate
  23. /** A protocol defining the events that can be emitted by the FSTWatchStream. */
  24. @protocol FSTWatchStreamDelegate <NSObject>
  25. /** Called by the FSTWatchStream when it is ready to accept outbound request messages. */
  26. - (void)watchStreamDidOpen;
  27. /**
  28. * Called by the FSTWatchStream with changes and the snapshot versions included in in the
  29. * WatchChange responses sent back by the server.
  30. */
  31. - (void)watchStreamDidChange:(FSTWatchChange *)change
  32. snapshotVersion:(const firebase::firestore::model::SnapshotVersion &)snapshotVersion;
  33. /**
  34. * Called by the FSTWatchStream when the underlying streaming RPC is interrupted for whatever
  35. * reason, usually because of an error, but possibly due to an idle timeout. The error passed to
  36. * this method may be nil, in which case the stream was closed without attributable fault.
  37. *
  38. * NOTE: This will not be called after `stop` is called on the stream. See "Starting and Stopping"
  39. * on FSTStream for details.
  40. */
  41. - (void)watchStreamWasInterruptedWithError:(const firebase::firestore::util::Status &)error;
  42. @end
  43. #pragma mark - FSTWriteStreamDelegate
  44. @protocol FSTWriteStreamDelegate <NSObject>
  45. /** Called by the FSTWriteStream when it is ready to accept outbound request messages. */
  46. - (void)writeStreamDidOpen;
  47. /**
  48. * Called by the FSTWriteStream upon a successful handshake response from the server, which is the
  49. * receiver's cue to send any pending writes.
  50. */
  51. - (void)writeStreamDidCompleteHandshake;
  52. /**
  53. * Called by the FSTWriteStream upon receiving a StreamingWriteResponse from the server that
  54. * contains mutation results.
  55. */
  56. - (void)writeStreamDidReceiveResponseWithVersion:
  57. (const firebase::firestore::model::SnapshotVersion &)commitVersion
  58. mutationResults:(NSArray<FSTMutationResult *> *)results;
  59. /**
  60. * Called when the FSTWriteStream's underlying RPC is interrupted for whatever reason, usually
  61. * because of an error, but possibly due to an idle timeout. The error passed to this method may be
  62. * nil, in which case the stream was closed without attributable fault.
  63. *
  64. * NOTE: This will not be called after `stop` is called on the stream. See "Starting and Stopping"
  65. * on FSTStream for details.
  66. */
  67. - (void)writeStreamWasInterruptedWithError:(const firebase::firestore::util::Status &)error;
  68. @end
  69. NS_ASSUME_NONNULL_END