Expose webSocketDidOpen in RCTReconnectingWebSocket

Summary: Expose webSocketDidOpen in RCTReconnectingWebSocket in order to get notified when the reconnecting websocket is opened to the endpoint.

Reviewed By: emilsjolander

Differential Revision: D5725547

fbshipit-source-id: e904c5a84d670ecf936993ec1739614f99fce09c
This commit is contained in:
Sebastian Lund 2017-08-29 07:59:40 -07:00 committed by Facebook Github Bot
parent b11656a727
commit bf67345b3b
4 changed files with 15 additions and 0 deletions

View File

@ -15,6 +15,8 @@
@protocol RCTWebSocketProtocolDelegate
- (void)webSocketDidOpen:(RCTSRWebSocket *)webSocket;
- (void)webSocket:(RCTSRWebSocket *)webSocket didReceiveMessage:(id)message;
- (void)webSocket:(RCTSRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;

View File

@ -101,6 +101,11 @@ static void my_nwlog_legacy_v(int level, char *format, va_list args) {
});
}
- (void)webSocketDidOpen:(RCTSRWebSocket *)webSocket
{
[self.delegate webSocketDidOpen:webSocket];
}
- (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error
{
[self reconnect];

View File

@ -66,6 +66,10 @@
}
}
- (void)webSocketDidOpen:(RCTSRWebSocket *)webSocket
{
}
- (void)webSocket:(RCTSRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean
{
}

View File

@ -132,6 +132,10 @@ static BOOL isSupportedVersion(NSNumber *version)
}
}
- (void)webSocketDidOpen:(RCTSRWebSocket *)webSocket
{
}
- (void)webSocket:(RCTSRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean
{
}