RCTReconnectingWebSocket.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #import <React/RCTDefines.h>
  8. #if RCT_DEV // Only supported in dev mode
  9. @class RCTReconnectingWebSocket;
  10. @protocol RCTReconnectingWebSocketDelegate
  11. - (void)reconnectingWebSocketDidOpen:(RCTReconnectingWebSocket *)webSocket;
  12. - (void)reconnectingWebSocket:(RCTReconnectingWebSocket *)webSocket didReceiveMessage:(id)message;
  13. /** Sent when the socket has closed due to error or clean shutdown. An automatic reconnect will start shortly. */
  14. - (void)reconnectingWebSocketDidClose:(RCTReconnectingWebSocket *)webSocket;
  15. @end
  16. @interface RCTReconnectingWebSocket : NSObject
  17. /** Delegate will be messaged on the given queue (required). */
  18. - (instancetype)initWithURL:(NSURL *)url queue:(dispatch_queue_t)queue;
  19. @property (nonatomic, weak) id<RCTReconnectingWebSocketDelegate> delegate;
  20. - (void)send:(id)data;
  21. - (void)start;
  22. - (void)stop;
  23. - (instancetype)initWithURL:(NSURL *)url __deprecated_msg("Use initWithURL:queue: instead");
  24. /** @brief Must be set before -start to have effect */
  25. @property (nonatomic, strong) dispatch_queue_t delegateDispatchQueue __deprecated_msg("Use initWithURL:queue: instead");
  26. @end
  27. #endif