SRDelegateController.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // Copyright (c) 2016-present, Facebook, Inc.
  3. // All rights reserved.
  4. //
  5. // This source code is licensed under the BSD-style license found in the
  6. // LICENSE file in the root directory of this source tree. An additional grant
  7. // of patent rights can be found in the PATENTS file in the same directory.
  8. //
  9. #import <Foundation/Foundation.h>
  10. #import "SRWebSocket.h"
  11. NS_ASSUME_NONNULL_BEGIN
  12. struct SRDelegateAvailableMethods {
  13. BOOL didReceiveMessage : 1;
  14. BOOL didReceiveMessageWithString : 1;
  15. BOOL didReceiveMessageWithData : 1;
  16. BOOL didOpen : 1;
  17. BOOL didFailWithError : 1;
  18. BOOL didCloseWithCode : 1;
  19. BOOL didReceivePing : 1;
  20. BOOL didReceivePong : 1;
  21. BOOL shouldConvertTextFrameToString : 1;
  22. };
  23. typedef struct SRDelegateAvailableMethods SRDelegateAvailableMethods;
  24. typedef void(^SRDelegateBlock)(id<SRWebSocketDelegate> _Nullable delegate, SRDelegateAvailableMethods availableMethods);
  25. @interface SRDelegateController : NSObject
  26. @property (nonatomic, weak) id<SRWebSocketDelegate> delegate;
  27. @property (atomic, readonly) SRDelegateAvailableMethods availableDelegateMethods;
  28. @property (nullable, nonatomic, strong) dispatch_queue_t dispatchQueue;
  29. @property (nullable, nonatomic, strong) NSOperationQueue *operationQueue;
  30. ///--------------------------------------
  31. #pragma mark - Perform
  32. ///--------------------------------------
  33. - (void)performDelegateBlock:(SRDelegateBlock)block;
  34. - (void)performDelegateQueueBlock:(dispatch_block_t)block;
  35. @end
  36. NS_ASSUME_NONNULL_END