@@ -56,9 +56,6 @@ - (void)closeIfNeverConnected;
5656@property (nonatomic , strong )
5757 NSURLSessionWebSocketTask *webSocketTask API_AVAILABLE (
5858 macos (10.15 ), ios(13.0 ), watchos(6.0 ), tvos(13.0 ));
59- #if !TARGET_OS_WATCH
60- @property(nonatomic, strong) FSRWebSocket *webSocket;
61- #endif // TARGET_OS_WATCH
6259@property(nonatomic, strong) NSNumber *connectionId;
6360@property (nonatomic , readwrite ) int totalFrames;
6461@property (nonatomic , readonly ) BOOL buffering;
@@ -72,9 +69,6 @@ - (void)nop:(NSTimer *)timer;
7269@implementation FWebSocketConnection
7370
7471@synthesize delegate;
75- #if !TARGET_OS_WATCH
76- @synthesize webSocket;
77- #endif // !TARGET_OS_WATCH
7872@synthesize connectionId;
7973
8074- (instancetype )initWith : (FRepoInfo *)repoInfo
@@ -126,33 +120,18 @@ - (instancetype)initWith:(FRepoInfo *)repoInfo
126120#elif
127121#error ("missing platform")
128122#endif
129- if (@available (watchOS 7.0 , *)) {
130- [[NSNotificationCenter defaultCenter ]
131- addObserverForName: resignName
132- object: nil
133- queue: opQueue
134- usingBlock: ^(NSNotification *_Nonnull note) {
135- FFLog (@" I-RDB083015" ,
136- @" Received notification that application "
137- @" will resign, "
138- @" closing web socket." );
139- [self onClosed ];
140- }];
141- }
123+ [[NSNotificationCenter defaultCenter ]
124+ addObserverForName: resignName
125+ object: nil
126+ queue: opQueue
127+ usingBlock: ^(NSNotification *_Nonnull note) {
128+ FFLog (@" I-RDB083015" ,
129+ @" Received notification that application "
130+ @" will resign, "
131+ @" closing web socket." );
132+ [self onClosed ];
133+ }];
142134 }
143- #if !TARGET_OS_WATCH
144- else {
145- // TODO(mmaksym): Remove googleAppID and userAgent from FSRWebSocket
146- // as they are passed via NSURLRequest.
147- self.webSocket =
148- [[FSRWebSocket alloc ] initWithURLRequest: req
149- queue: queue
150- googleAppID: googleAppID
151- andUserAgent: userAgent];
152- [self .webSocket setDelegateDispatchQueue: queue];
153- self.webSocket .delegate = self;
154- }
155- #endif // TARGET_OS_WATCH
156135 }
157136 return self;
158137}
@@ -219,11 +198,6 @@ - (void)open {
219198 // sending data.
220199 [self receiveWebSocketData ];
221200 }
222- #if !TARGET_OS_WATCH
223- else {
224- [self .webSocket open ];
225- }
226- #endif // TARGET_OS_WATCH
227201 dispatch_time_t when = dispatch_time (
228202 DISPATCH_TIME_NOW, kWebsocketConnectTimeout * NSEC_PER_SEC);
229203 dispatch_after (when, self.dispatchQueue , ^{
@@ -241,11 +215,6 @@ - (void)close {
241215 cancelWithCloseCode: NSURLSessionWebSocketCloseCodeNormalClosure
242216 reason: nil ];
243217 }
244- #if !TARGET_OS_WATCH
245- else {
246- [self .webSocket close ];
247- }
248- #endif // TARGET_OS_WATCH
249218}
250219
251220- (void )start {
@@ -391,31 +360,6 @@ - (void)receiveWebSocketData API_AVAILABLE(macos(10.15), ios(13.0),
391360 }];
392361}
393362
394- #if !TARGET_OS_WATCH
395-
396- #pragma mark SRWebSocketDelegate implementation
397-
398- - (void )webSocket:(FSRWebSocket *)webSocket didReceiveMessage:(id )message {
399- [self handleIncomingFrame: message];
400- }
401-
402- - (void )webSocket:(FSRWebSocket *)webSocket didFailWithError:(NSError *)error {
403- FFLog (@" I-RDB083010" , @" (wsc:%@ ) didFailWithError didFailWithError: %@ " ,
404- self.connectionId , [error description ]);
405- [self onClosed ];
406- }
407-
408- - (void )webSocket:(FSRWebSocket *)webSocket
409- didCloseWithCode:(NSInteger )code
410- reason:(NSString *)reason
411- wasClean:(BOOL )wasClean {
412- FFLog (@" I-RDB083011" , @" (wsc:%@ ) didCloseWithCode: %ld %@ " ,
413- self.connectionId , (long )code, reason);
414- [self onClosed ];
415- }
416-
417- #endif // !TARGET_OS_WATCH
418-
419363// Common to both SRWebSocketDelegate and URLSessionWebSocketDelegate.
420364
421365- (void )webSocketDidOpen {
@@ -454,12 +398,6 @@ - (void)sendStringToWebSocket:(NSString *)string {
454398 }
455399 }];
456400 }
457- #if !TARGET_OS_WATCH
458- else {
459- // Use existing SocketRocket implementation.
460- [self .webSocket send: string];
461- }
462- #endif // !TARGET_OS_WATCH
463401}
464402
465403/* *
@@ -485,11 +423,6 @@ - (void)closeIfNeverConnected {
485423 NSURLSessionWebSocketCloseCodeNoStatusReceived
486424 reason: nil ];
487425 }
488- #if !TARGET_OS_WATCH
489- else {
490- [self .webSocket close ];
491- }
492- #endif // TARGET_OS_WATCH
493426 }
494427}
495428
@@ -509,9 +442,6 @@ - (void)onClosed {
509442 watchOS 6.0 , *)) {
510443 self.webSocketTask = nil ;
511444 }
512- #if !TARGET_OS_WATCH
513- self.webSocket = nil ;
514- #endif // TARGET_OS_WATCH
515445 if (keepAlive.isValid ) {
516446 [keepAlive invalidate ];
517447 }
0 commit comments