Skip to content

Commit

Permalink
Update SocketRocket dependency to 0.5.2-ably-8
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrence-forooghian committed Nov 9, 2020
1 parent bec9948 commit 68d002f
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Ably-SoakTest-AppUITests/SoakTestWebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Ably.Private
import SocketRocketAblyFork

class SoakTestWebSocket: NSObject, ARTWebSocket {
var readyState: SRReadyState
var readyState: ARTSRReadyState
var queue: DispatchQueue!
var delegate: ARTWebSocketDelegate?

Expand Down Expand Up @@ -60,7 +60,7 @@ class SoakTestWebSocket: NSObject, ARTWebSocket {
}

self.doIfStillOpen(afterSecondsBetween: 3.0 ... 300.0) {
let (code, clean) : (SRStatusCode, Bool) = [
let (code, clean) : (ARTSRStatusCode, Bool) = [
(.codeAbnormal, false),
(.codeNormal, true),
(.codeGoingAway, true),
Expand Down
2 changes: 1 addition & 1 deletion Ably.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Pod::Spec.new do |s|
s.source_files = 'Source/**/*.{h,m,swift}'
s.private_header_files = 'Source/*+Private.h', 'Source/Private/*.h'
s.module_map = 'Source/Ably.modulemap'
s.dependency 'SocketRocketAblyFork', '0.5.2-ably-7'
s.dependency 'SocketRocketAblyFork', '0.5.2-ably-8'
s.dependency 'msgpack', '0.3.1'
s.dependency 'ULID', '1.1.0'
s.dependency 'AblyDeltaCodec', '1.2.0'
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github "ably-forks/SocketRocket" == 0.5.2-ably-7
github "ably-forks/SocketRocket" == 0.5.2-ably-8
github "ably/delta-codec-cocoa" == 1.2.0
github "rvi/msgpack-objective-C" == 0.3.1
github "whitesmith/ulid" == 1.1.0
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github "Quick/Nimble" "v9.0.0"
github "Quick/Quick" "v3.0.0"
github "SwiftyJSON/SwiftyJSON" "4.3.0"
github "ably-forks/SocketRocket" "0.5.2-ably-7"
github "ably-forks/SocketRocket" "0.5.2-ably-8"
github "ably/delta-codec-cocoa" "1.2.0"
github "rvi/msgpack-objective-C" "0.3.1"
github "whitesmith/Aspects" "1.4.2-ws1"
Expand Down
4 changes: 2 additions & 2 deletions Source/ARTWebSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ NS_ASSUME_NONNULL_BEGIN
@protocol ARTWebSocketDelegate;

/**
This protocol has the subset of SRWebSocket we actually use.
This protocol has the subset of ARTSRWebSocket we actually use.
*/
@protocol ARTWebSocket <NSObject>

@property (nonatomic, weak) id <ARTWebSocketDelegate> _Nullable delegate;
@property (atomic, assign, readonly) SRReadyState readyState;
@property (atomic, assign, readonly) ARTSRReadyState readyState;

- (instancetype)initWithURLRequest:(NSURLRequest *)request;

Expand Down
2 changes: 1 addition & 1 deletion Source/ARTWebSocketTransport+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import <Ably/ARTWebSocketTransport.h>
#import <Ably/CompatibilityMacros.h>
#import <SocketRocketAblyFork/SRWebSocket.h>
#import <SocketRocketAblyFork/ARTSRWebSocket.h>
#import <Ably/ARTEncoder.h>
#import <Ably/ARTAuth.h>
#import <Ably/ARTWebSocket.h>
Expand Down
28 changes: 14 additions & 14 deletions Source/ARTWebSocketTransport.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
ARTWsTlsError = 1015
};

NSString *WebSocketStateToStr(SRReadyState state);
NSString *WebSocketStateToStr(ARTSRReadyState state);

@interface SRWebSocket () <ARTWebSocket>
@interface ARTSRWebSocket () <ARTWebSocket>
@end

Class configuredWebsocketClass = nil;
Expand Down Expand Up @@ -86,7 +86,7 @@ - (void)dealloc {
}

- (BOOL)send:(NSData *)data withSource:(id)decodedObject {
if (self.websocket.readyState == SR_OPEN) {
if (self.websocket.readyState == ARTSR_OPEN) {
if ([decodedObject isKindOfClass:[ARTProtocolMessage class]]) {
[_protocolMessagesLogger info:@"send %@", [decodedObject description]];
}
Expand Down Expand Up @@ -203,7 +203,7 @@ - (NSURL *)setupWebSocket:(__GENERIC(NSArray, NSURLQueryItem *) *)params withOpt

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

const Class websocketClass = configuredWebsocketClass ? configuredWebsocketClass : [SRWebSocket class];
const Class websocketClass = configuredWebsocketClass ? configuredWebsocketClass : [ARTSRWebSocket class];
self.websocket = [[websocketClass alloc] initWithURLRequest:request];
[self.websocket setDelegateDispatchQueue:_workQueue];
self.websocket.delegate = self;
Expand Down Expand Up @@ -254,7 +254,7 @@ - (NSString *)host {
}

- (ARTRealtimeTransportState)state {
if (self.websocket.readyState == SR_OPEN) {
if (self.websocket.readyState == ARTSR_OPEN) {
return ARTRealtimeTransportStateOpened;
}
return _state;
Expand All @@ -264,7 +264,7 @@ - (void)setState:(ARTRealtimeTransportState)state {
_state = state;
}

#pragma mark - SRWebSocketDelegate
#pragma mark - ARTSRWebSocketDelegate

// All delegate methods from SocketRocket are called from rest's serial queue,
// since we pass it as delegate queue on setupWebSocket. So we can safely
Expand Down Expand Up @@ -331,8 +331,8 @@ - (ARTRealtimeTransportError *)classifyError:(NSError *)error {
type = ARTRealtimeTransportErrorTypeHostUnreachable;
} else if ([error.domain isEqualToString:@"NSPOSIXErrorDomain"] && (error.code == 57 || error.code == 50)) {
type = ARTRealtimeTransportErrorTypeNoInternet;
} else if ([error.domain isEqualToString:SRWebSocketErrorDomain] && error.code == 2132) {
id status = error.userInfo[SRHTTPResponseErrorKey];
} else if ([error.domain isEqualToString:ARTSRWebSocketErrorDomain] && error.code == 2132) {
id status = error.userInfo[ARTSRHTTPResponseErrorKey];
if (status) {
return [[ARTRealtimeTransportError alloc] initWithError:error
badResponseCode:[(NSNumber *)status integerValue]
Expand All @@ -346,7 +346,7 @@ - (ARTRealtimeTransportError *)classifyError:(NSError *)error {
- (void)webSocket:(id<ARTWebSocket>)webSocket didReceiveMessage:(id)message {
[self.logger verbose:__FILE__ line:__LINE__ message:@"R:%p WS:%p websocket did receive message", _delegate, self];

if (self.websocket.readyState == SR_CLOSED) {
if (self.websocket.readyState == ARTSR_CLOSED) {
[self.logger debug:__FILE__ line:__LINE__ message:@"R:%p WS:%p websocket is closed, message has been ignored", _delegate, self];
return;
}
Expand Down Expand Up @@ -383,15 +383,15 @@ - (void)webSocketMessageProtocol:(ARTProtocolMessage *)message {

@end

NSString *WebSocketStateToStr(SRReadyState state) {
NSString *WebSocketStateToStr(ARTSRReadyState state) {
switch (state) {
case SR_CONNECTING:
case ARTSR_CONNECTING:
return @"Connecting"; //0
case SR_OPEN:
case ARTSR_OPEN:
return @"Open"; //1
case SR_CLOSING:
case ARTSR_CLOSING:
return @"Closing"; //2
case SR_CLOSED:
case ARTSR_CLOSED:
return @"Closed"; //3
}
}
Expand Down
2 changes: 1 addition & 1 deletion Spec/TestUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ class TestProxyTransport: ARTWebSocketTransport {

private func setupFakeNetworkResponse(_ networkResponse: FakeNetworkResponse) {
var hook: AspectToken?
hook = SRWebSocket.testSuite_replaceClassMethod(#selector(SRWebSocket.open)) {
hook = ARTSRWebSocket.testSuite_replaceClassMethod(#selector(ARTSRWebSocket.open)) {
if TestProxyTransport.fakeNetworkResponse == nil {
return
}
Expand Down

0 comments on commit 68d002f

Please sign in to comment.