Use a dispatch queue for websocket operations

Summary:
This diff ensures that all operations on the socket are put into a serial background queue, including delegate callbacks.

All operations are executed asynchronously except disconnect, which is made synchronous as to guarantee no resources are accessed after the call.

Reviewed By: fabiomassimo

Differential Revision: D35254499

fbshipit-source-id: 33d93926f7bfc8948095c59f12ca31f0a932b8ae
This commit is contained in:
Lorenzo Blasa
2022-04-12 02:30:02 -07:00
committed by Facebook GitHub Bot
parent 2bafe32f2a
commit f1fe66afd9
3 changed files with 141 additions and 72 deletions

View File

@@ -40,11 +40,12 @@ NS_ASSUME_NONNULL_BEGIN
/// Send a message to the endpoint.
/// @param message The message as text to be sent to the endpoint.
/// @param error A pointer to variable for an `NSError` object.
/// If an error occurs, the pointer is set to an `NSError` object containing
/// information about the error. You may specify `nil` to ignore the error
/// information.
- (void)send:(NSString*)message error:(NSError**)error;
/// @param completionHandler A completion handler for the send operation.
/// If an error occurs, the handler will be called with an `NSError` object
/// containing information about the error. You may specify `nil` to ignore the
/// error information.
- (void)send:(NSString*)message
withCompletionHandler:(void (^_Nullable)(NSError*))completionHandler;
@end