diff --git a/Ably.xcodeproj/project.pbxproj b/Ably.xcodeproj/project.pbxproj index a50a6fb64..4dc7c17a2 100644 --- a/Ably.xcodeproj/project.pbxproj +++ b/Ably.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -81,24 +81,24 @@ 211A60D729D6D2C300D169C5 /* BackoffRetryDelayCalculatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2132C31829D5E574000C4355 /* BackoffRetryDelayCalculatorTests.swift */; }; 211A60D829D6D2C400D169C5 /* BackoffRetryDelayCalculatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2132C31829D5E574000C4355 /* BackoffRetryDelayCalculatorTests.swift */; }; 211A60D929D6D2C500D169C5 /* BackoffRetryDelayCalculatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2132C31829D5E574000C4355 /* BackoffRetryDelayCalculatorTests.swift */; }; - 211A60DB29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A60DC29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A60DD29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A60DF29D7272000D169C5 /* ARTConnectionStateChangeMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeMetadata.m */; }; - 211A60E029D7272000D169C5 /* ARTConnectionStateChangeMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeMetadata.m */; }; - 211A60E129D7272000D169C5 /* ARTConnectionStateChangeMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeMetadata.m */; }; - 211A60FB29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A60FC29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A60FD29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A60FF29D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m */; }; - 211A610029D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m */; }; - 211A610129D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m */; }; - 211A610329DA05C700D169C5 /* ARTAttachRequestMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A610229DA05C700D169C5 /* ARTAttachRequestMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A610429DA05C700D169C5 /* ARTAttachRequestMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A610229DA05C700D169C5 /* ARTAttachRequestMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A610529DA05C700D169C5 /* ARTAttachRequestMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A610229DA05C700D169C5 /* ARTAttachRequestMetadata.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 211A610729DA05D700D169C5 /* ARTAttachRequestMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A610629DA05D700D169C5 /* ARTAttachRequestMetadata.m */; }; - 211A610829DA05D700D169C5 /* ARTAttachRequestMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A610629DA05D700D169C5 /* ARTAttachRequestMetadata.m */; }; - 211A610929DA05D700D169C5 /* ARTAttachRequestMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A610629DA05D700D169C5 /* ARTAttachRequestMetadata.m */; }; + 211A60DB29D726F800D169C5 /* ARTConnectionStateChangeParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A60DC29D726F800D169C5 /* ARTConnectionStateChangeParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A60DD29D726F800D169C5 /* ARTConnectionStateChangeParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A60DF29D7272000D169C5 /* ARTConnectionStateChangeParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeParams.m */; }; + 211A60E029D7272000D169C5 /* ARTConnectionStateChangeParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeParams.m */; }; + 211A60E129D7272000D169C5 /* ARTConnectionStateChangeParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeParams.m */; }; + 211A60FB29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A60FC29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A60FD29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A60FF29D8ABF100D169C5 /* ARTChannelStateChangeParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeParams.m */; }; + 211A610029D8ABF100D169C5 /* ARTChannelStateChangeParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeParams.m */; }; + 211A610129D8ABF100D169C5 /* ARTChannelStateChangeParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeParams.m */; }; + 211A610329DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A610229DA05C700D169C5 /* ARTAttachRequestParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A610429DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A610229DA05C700D169C5 /* ARTAttachRequestParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A610529DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 211A610229DA05C700D169C5 /* ARTAttachRequestParams.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 211A610729DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A610629DA05D700D169C5 /* ARTAttachRequestParams.m */; }; + 211A610829DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A610629DA05D700D169C5 /* ARTAttachRequestParams.m */; }; + 211A610929DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */ = {isa = PBXBuildFile; fileRef = 211A610629DA05D700D169C5 /* ARTAttachRequestParams.m */; }; 2124B78729DB127900AD8361 /* MockVersion2Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2124B78629DB127900AD8361 /* MockVersion2Log.swift */; }; 2124B78829DB127900AD8361 /* MockVersion2Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2124B78629DB127900AD8361 /* MockVersion2Log.swift */; }; 2124B78929DB127900AD8361 /* MockVersion2Log.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2124B78629DB127900AD8361 /* MockVersion2Log.swift */; }; @@ -1143,12 +1143,12 @@ 21113B5E29DDDDD000652C86 /* LogAdapterTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogAdapterTests.swift; sourceTree = ""; }; 21113B6229DDF7E800652C86 /* ARTInternalLogTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTInternalLogTests.m; sourceTree = ""; }; 21113B5829DCA4C700652C86 /* DataGatherer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataGatherer.swift; sourceTree = ""; }; - 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ARTConnectionStateChangeMetadata.h; path = PrivateHeaders/Ably/ARTConnectionStateChangeMetadata.h; sourceTree = ""; }; - 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeMetadata.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTConnectionStateChangeMetadata.m; sourceTree = ""; }; - 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ARTChannelStateChangeMetadata.h; path = PrivateHeaders/Ably/ARTChannelStateChangeMetadata.h; sourceTree = ""; }; - 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTChannelStateChangeMetadata.m; sourceTree = ""; }; - 211A610229DA05C700D169C5 /* ARTAttachRequestMetadata.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ARTAttachRequestMetadata.h; path = PrivateHeaders/Ably/ARTAttachRequestMetadata.h; sourceTree = ""; }; - 211A610629DA05D700D169C5 /* ARTAttachRequestMetadata.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTAttachRequestMetadata.m; sourceTree = ""; }; + 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ARTConnectionStateChangeParams.h; path = PrivateHeaders/Ably/ARTConnectionStateChangeParams.h; sourceTree = ""; }; + 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTConnectionStateChangeParams.m; sourceTree = ""; }; + 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ARTChannelStateChangeParams.h; path = PrivateHeaders/Ably/ARTChannelStateChangeParams.h; sourceTree = ""; }; + 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTChannelStateChangeParams.m; sourceTree = ""; }; + 211A610229DA05C700D169C5 /* ARTAttachRequestParams.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ARTAttachRequestParams.h; path = PrivateHeaders/Ably/ARTAttachRequestParams.h; sourceTree = ""; }; + 211A610629DA05D700D169C5 /* ARTAttachRequestParams.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ARTAttachRequestParams.m; sourceTree = ""; }; 2124B78629DB127900AD8361 /* MockVersion2Log.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockVersion2Log.swift; sourceTree = ""; }; 2124B78A29DB12A900AD8361 /* ARTVersion2Log.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ARTVersion2Log.h; path = PrivateHeaders/Ably/ARTVersion2Log.h; sourceTree = ""; }; 2124B78E29DB13BD00AD8361 /* ARTInternalLog.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ARTInternalLog.m; sourceTree = ""; }; @@ -1919,15 +1919,15 @@ 96A507BB1A3791490077CDF8 /* ARTRealtime.h */, 1C05CF1E1AC1D7EB00687AC9 /* ARTRealtime+Private.h */, 96A507BC1A3791490077CDF8 /* ARTRealtime.m */, - 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h */, - 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeMetadata.m */, + 211A60DA29D726F800D169C5 /* ARTConnectionStateChangeParams.h */, + 211A60DE29D7272000D169C5 /* ARTConnectionStateChangeParams.m */, D746AE3A1BBC5AE1003ECEF8 /* ARTRealtimeChannel.h */, D746AE421BBC5CD0003ECEF8 /* ARTRealtimeChannel+Private.h */, D746AE3B1BBC5AE1003ECEF8 /* ARTRealtimeChannel.m */, - 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h */, - 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m */, - 211A610229DA05C700D169C5 /* ARTAttachRequestMetadata.h */, - 211A610629DA05D700D169C5 /* ARTAttachRequestMetadata.m */, + 211A60FA29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h */, + 211A60FE29D8ABF100D169C5 /* ARTChannelStateChangeParams.m */, + 211A610229DA05C700D169C5 /* ARTAttachRequestParams.h */, + 211A610629DA05D700D169C5 /* ARTAttachRequestParams.m */, D76F153923DB010C00B5133C /* ARTRealtimeChannelOptions.h */, D76F153A23DB010C00B5133C /* ARTRealtimeChannelOptions.m */, D7D29B401BE3DD0600374295 /* ARTConnection.h */, @@ -2232,7 +2232,7 @@ D777EEE0206285CF002EBA03 /* ARTDeviceIdentityTokenDetails.h in Headers */, 2124B79F29DB14D000AD8361 /* ARTLogAdapter.h in Headers */, 215F76032922C76C009E0E76 /* ARTClientInformation+Private.h in Headers */, - 211A610329DA05C700D169C5 /* ARTAttachRequestMetadata.h in Headers */, + 211A610329DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */, 96BF615E1A35C1C8004CF2B3 /* ARTTypes.h in Headers */, EB503C881C7E4A090053AF00 /* ARTClientOptions+Private.h in Headers */, EB2D84F71CD75CCE00F23CDA /* ARTReachability.h in Headers */, @@ -2288,7 +2288,7 @@ D746AE401BBC5B14003ECEF8 /* ARTEventEmitter.h in Headers */, D746AE531BBD85C5003ECEF8 /* ARTChannels.h in Headers */, D7D8F82D1BC2C706009718F2 /* ARTTokenParams.h in Headers */, - 211A60FB29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h in Headers */, + 211A60FB29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h in Headers */, EB0505FC1C5BD7C4006BA7E2 /* ARTBaseMessage+Private.h in Headers */, D777EEE42063A64E002EBA03 /* ARTNSMutableRequest+ARTPush.h in Headers */, EB20F8D71C653F2300EF3978 /* ARTPresence+Private.h in Headers */, @@ -2309,7 +2309,7 @@ 2105ED1E29E7242400DE6D67 /* ARTLogAdapter+Testing.h in Headers */, EBF2285B1F4D9AD6009091DD /* ARTWebSocketTransport+Private.h in Headers */, EBFFAC191E97919C003E7326 /* ARTLocalDevice+Private.h in Headers */, - 211A60DB29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h in Headers */, + 211A60DB29D726F800D169C5 /* ARTConnectionStateChangeParams.h in Headers */, D737F826263AF4CE0064FA05 /* ARTFallbackHosts.h in Headers */, D746AE4F1BBD84E7003ECEF8 /* ARTChannelOptions.h in Headers */, D7588AF31BFF91B800BB8279 /* ARTURLSessionServerTrust.h in Headers */, @@ -2406,8 +2406,8 @@ D710D60F21949DDB008F54AD /* ARTHTTPPaginatedResponse.h in Headers */, D710D58A21949D29008F54AD /* ARTMessage.h in Headers */, D710D68721949ED5008F54AD /* ARTNSArray+ARTFunctional.h in Headers */, - 211A60DC29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h in Headers */, - 211A60FC29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h in Headers */, + 211A60DC29D726F800D169C5 /* ARTConnectionStateChangeParams.h in Headers */, + 211A60FC29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h in Headers */, D5BB211826AA9A9E00AA5F3E /* ARTNSMutableDictionary+ARTDictionaryUtil.h in Headers */, D710D5BA21949D4F008F54AD /* ARTClientOptions+Private.h in Headers */, D710D58521949D28008F54AD /* ARTChannel.h in Headers */, @@ -2467,7 +2467,7 @@ D710D51921949C42008F54AD /* ARTDeviceDetails.h in Headers */, D710D50621949C18008F54AD /* ARTConnection+Private.h in Headers */, D710D54E21949C66008F54AD /* ARTNSMutableRequest+ARTPush.h in Headers */, - 211A610429DA05C700D169C5 /* ARTAttachRequestMetadata.h in Headers */, + 211A610429DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */, D7D06F1026330E2800DEBDAD /* ARTHttp+Private.h in Headers */, 210F67A329E9D718007B9345 /* ARTRealtimeTransportFactory.h in Headers */, EB1B541A22FB1D7F006A59AC /* ARTPushChannelSubscriptions+Private.h in Headers */, @@ -2574,8 +2574,8 @@ D710D61921949DDC008F54AD /* ARTHTTPPaginatedResponse.h in Headers */, D710D5B021949D2A008F54AD /* ARTMessage.h in Headers */, D710D5CA21949D50008F54AD /* ARTClientOptions+Private.h in Headers */, - 211A60DD29D726F800D169C5 /* ARTConnectionStateChangeMetadata.h in Headers */, - 211A60FD29D8ABCF00D169C5 /* ARTChannelStateChangeMetadata.h in Headers */, + 211A60DD29D726F800D169C5 /* ARTConnectionStateChangeParams.h in Headers */, + 211A60FD29D8ABCF00D169C5 /* ARTChannelStateChangeParams.h in Headers */, D710D5AB21949D2A008F54AD /* ARTChannel.h in Headers */, EB1B541322FB1AB4006A59AC /* ARTPushChannel+Private.h in Headers */, D54C55A926957FDE00729EC4 /* ARTNSURL+ARTUtils.h in Headers */, @@ -2635,7 +2635,7 @@ D710D52B21949C44008F54AD /* ARTDeviceDetails.h in Headers */, D710D51221949C19008F54AD /* ARTConnection+Private.h in Headers */, D710D55421949C67008F54AD /* ARTNSMutableRequest+ARTPush.h in Headers */, - 211A610529DA05C700D169C5 /* ARTAttachRequestMetadata.h in Headers */, + 211A610529DA05C700D169C5 /* ARTAttachRequestParams.h in Headers */, D7D06F1126330E2900DEBDAD /* ARTHttp+Private.h in Headers */, 210F67A429E9D718007B9345 /* ARTRealtimeTransportFactory.h in Headers */, EB1B541B22FB1D7F006A59AC /* ARTPushChannelSubscriptions+Private.h in Headers */, @@ -3083,7 +3083,7 @@ 217D182B254222F500DFF07E /* ARTSRWebSocket.m in Sources */, EB2D5A911CC941A700AD1A67 /* ARTRealtimeTransport.m in Sources */, D746AE391BBC3201003ECEF8 /* ARTMessage.m in Sources */, - 211A60FF29D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m in Sources */, + 211A60FF29D8ABF100D169C5 /* ARTChannelStateChangeParams.m in Sources */, D737F829263AF4CE0064FA05 /* ARTFallbackHosts.m in Sources */, D7E0FEB9211DE94700659FAA /* ARTNSMutableRequest+ARTRest.m in Sources */, D7B621991E4A762A00684474 /* ARTPushChannel.m in Sources */, @@ -3161,7 +3161,7 @@ D70C36C6233E6831002FD6E3 /* ARTFormEncode.m in Sources */, D7AE18D31E5B410F00478D82 /* ARTPushChannelSubscriptions.m in Sources */, 1CD8DCA01B1C7315007EAF36 /* ARTDefault.m in Sources */, - 211A610729DA05D700D169C5 /* ARTAttachRequestMetadata.m in Sources */, + 211A610729DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */, D7AE18CF1E5B40FE00478D82 /* ARTPushDeviceRegistrations.m in Sources */, D7B621951E4A6FE600684474 /* ARTDeviceDetails.m in Sources */, D7588AF41BFF91B800BB8279 /* ARTURLSessionServerTrust.m in Sources */, @@ -3172,7 +3172,7 @@ 2132C2F929D5BE3D000C4355 /* ARTRetrySequence.m in Sources */, D746AE501BBD84E7003ECEF8 /* ARTChannelOptions.m in Sources */, EB89D4051C61C1A4007FA5B7 /* ARTRestChannels.m in Sources */, - 211A60DF29D7272000D169C5 /* ARTConnectionStateChangeMetadata.m in Sources */, + 211A60DF29D7272000D169C5 /* ARTConnectionStateChangeParams.m in Sources */, 217D1834254222F600DFF07E /* ARTSRURLUtilities.m in Sources */, 2132C21E29D23196000C4355 /* ARTErrorChecker.m in Sources */, D777EEE1206285CF002EBA03 /* ARTDeviceIdentityTokenDetails.m in Sources */, @@ -3324,7 +3324,7 @@ 217D1842254222F700DFF07E /* ARTSRWebSocket.m in Sources */, D710D4F021949C0D008F54AD /* ARTRealtimePresence.m in Sources */, D710D4F321949C0D008F54AD /* ARTRealtimeChannels.m in Sources */, - 211A610029D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m in Sources */, + 211A610029D8ABF100D169C5 /* ARTChannelStateChangeParams.m in Sources */, D737F82A263AF4CE0064FA05 /* ARTFallbackHosts.m in Sources */, D710D53521949C54008F54AD /* ARTDevicePushDetails.m in Sources */, D710D62F21949E03008F54AD /* ARTDataQuery.m in Sources */, @@ -3402,7 +3402,7 @@ D710D5D121949D78008F54AD /* ARTAuthDetails.m in Sources */, D710D4EC21949C0D008F54AD /* ARTRealtime.m in Sources */, D710D4ED21949C0D008F54AD /* ARTRealtimeChannel.m in Sources */, - 211A610829DA05D700D169C5 /* ARTAttachRequestMetadata.m in Sources */, + 211A610829DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */, D710D67021949E78008F54AD /* ARTNSDictionary+ARTDictionaryUtil.m in Sources */, D710D48C21949A97008F54AD /* ARTConstants.m in Sources */, D710D5DA21949D78008F54AD /* ARTBaseMessage.m in Sources */, @@ -3413,7 +3413,7 @@ 2132C2FA29D5BE3D000C4355 /* ARTRetrySequence.m in Sources */, D710D57421949CC4008F54AD /* ARTPushDeviceRegistrations.m in Sources */, D710D5D821949D78008F54AD /* ARTChannelOptions.m in Sources */, - 211A60E029D7272000D169C5 /* ARTConnectionStateChangeMetadata.m in Sources */, + 211A60E029D7272000D169C5 /* ARTConnectionStateChangeParams.m in Sources */, 217D184B254222F700DFF07E /* ARTSRURLUtilities.m in Sources */, 2132C21F29D23196000C4355 /* ARTErrorChecker.m in Sources */, D73B655923EF2B2900D459A6 /* ARTDeltaCodec.m in Sources */, @@ -3449,7 +3449,7 @@ D710D50021949C0E008F54AD /* ARTRealtimePresence.m in Sources */, D710D50321949C0E008F54AD /* ARTRealtimeChannels.m in Sources */, D737F82B263AF4CE0064FA05 /* ARTFallbackHosts.m in Sources */, - 211A610129D8ABF100D169C5 /* ARTChannelStateChangeMetadata.m in Sources */, + 211A610129D8ABF100D169C5 /* ARTChannelStateChangeParams.m in Sources */, D710D54721949C55008F54AD /* ARTDevicePushDetails.m in Sources */, D710D63F21949E04008F54AD /* ARTDataQuery.m in Sources */, D710D54321949C55008F54AD /* ARTPush.m in Sources */, @@ -3527,7 +3527,7 @@ D710D4FC21949C0E008F54AD /* ARTRealtime.m in Sources */, D710D4FD21949C0E008F54AD /* ARTRealtimeChannel.m in Sources */, D710D65621949E77008F54AD /* ARTNSDictionary+ARTDictionaryUtil.m in Sources */, - 211A610929DA05D700D169C5 /* ARTAttachRequestMetadata.m in Sources */, + 211A610929DA05D700D169C5 /* ARTAttachRequestParams.m in Sources */, D710D48E21949A98008F54AD /* ARTConstants.m in Sources */, D710D60021949D79008F54AD /* ARTBaseMessage.m in Sources */, D520C4DB26809BB5000012B2 /* ARTStringifiable.m in Sources */, @@ -3538,7 +3538,7 @@ 2132C2FB29D5BE3D000C4355 /* ARTRetrySequence.m in Sources */, D710D5FE21949D79008F54AD /* ARTChannelOptions.m in Sources */, D5BB213826AAA60500AA5F3E /* ARTNSError+ARTUtils.m in Sources */, - 211A60E129D7272000D169C5 /* ARTConnectionStateChangeMetadata.m in Sources */, + 211A60E129D7272000D169C5 /* ARTConnectionStateChangeParams.m in Sources */, 217D1862254222FA00DFF07E /* ARTSRURLUtilities.m in Sources */, 2132C22029D23196000C4355 /* ARTErrorChecker.m in Sources */, D73B655A23EF2B2900D459A6 /* ARTDeltaCodec.m in Sources */, diff --git a/Source/ARTAttachRequestMetadata.m b/Source/ARTAttachRequestParams.m similarity index 88% rename from Source/ARTAttachRequestMetadata.m rename to Source/ARTAttachRequestParams.m index cb06058d0..f72914eba 100644 --- a/Source/ARTAttachRequestMetadata.m +++ b/Source/ARTAttachRequestParams.m @@ -1,6 +1,6 @@ -#import "ARTAttachRequestMetadata.h" +#import "ARTAttachRequestParams.h" -@implementation ARTAttachRequestMetadata +@implementation ARTAttachRequestParams - (instancetype)initWithReason:(ARTErrorInfo *)reason { return [self initWithReason:reason channelSerial:nil]; diff --git a/Source/ARTChannelStateChangeMetadata.m b/Source/ARTChannelStateChangeParams.m similarity index 90% rename from Source/ARTChannelStateChangeMetadata.m rename to Source/ARTChannelStateChangeParams.m index f5c1a3510..e00f5cc54 100644 --- a/Source/ARTChannelStateChangeMetadata.m +++ b/Source/ARTChannelStateChangeParams.m @@ -1,6 +1,6 @@ -#import "ARTChannelStateChangeMetadata.h" +#import "ARTChannelStateChangeParams.h" -@implementation ARTChannelStateChangeMetadata +@implementation ARTChannelStateChangeParams - (instancetype)initWithState:(ARTState)state { return [self initWithState:state errorInfo:nil storeErrorInfo:NO]; diff --git a/Source/ARTConnectionStateChangeMetadata.m b/Source/ARTConnectionStateChangeParams.m similarity index 82% rename from Source/ARTConnectionStateChangeMetadata.m rename to Source/ARTConnectionStateChangeParams.m index e7dca624a..97eeaae0f 100644 --- a/Source/ARTConnectionStateChangeMetadata.m +++ b/Source/ARTConnectionStateChangeParams.m @@ -1,6 +1,6 @@ -#import "ARTConnectionStateChangeMetadata.h" +#import "ARTConnectionStateChangeParams.h" -@implementation ARTConnectionStateChangeMetadata +@implementation ARTConnectionStateChangeParams - (instancetype)init { return [self initWithErrorInfo:nil]; diff --git a/Source/ARTRealtime.m b/Source/ARTRealtime.m index 7bf008227..c9877678c 100644 --- a/Source/ARTRealtime.m +++ b/Source/ARTRealtime.m @@ -44,9 +44,9 @@ #import "ARTCrypto.h" #import "ARTDeviceIdentityTokenDetails.h" #import "ARTErrorChecker.h" -#import "ARTConnectionStateChangeMetadata.h" -#import "ARTChannelStateChangeMetadata.h" -#import "ARTAttachRequestMetadata.h" +#import "ARTConnectionStateChangeParams.h" +#import "ARTChannelStateChangeParams.h" +#import "ARTAttachRequestParams.h" #import "ARTRetrySequence.h" #import "ARTBackoffRetryDelayCalculator.h" #import "ARTTypes+Private.h" @@ -332,7 +332,7 @@ - (void)auth:(ARTAuthInternal *)auth didAuthorize:(ARTTokenDetails *)tokenDetail default: { // Client state is NOT Connecting or Connected, so it should start a new connection ARTLogDebug(self.logger, @"RS:%p new connection from successfull authorize %@", self.rest, tokenDetails); - [self transition:ARTRealtimeConnecting withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeConnecting withParams:[[ARTConnectionStateChangeParams alloc] init]]; waitForResponse(); break; } @@ -430,11 +430,11 @@ - (void)connect { } - (void)_connect { - if(self.connection.state_nosync == ARTRealtimeClosing) { + if (self.connection.state_nosync == ARTRealtimeClosing) { // New connection _transport = nil; } - [self transition:ARTRealtimeConnecting withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeConnecting withParams:[[ARTConnectionStateChangeParams alloc] init]]; } - (void)close { @@ -461,10 +461,10 @@ - (void)_close { } case ARTRealtimeDisconnected: case ARTRealtimeSuspended: - [self transition:ARTRealtimeClosed withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeClosed withParams:[[ARTConnectionStateChangeParams alloc] init]]; break; case ARTRealtimeConnected: - [self transition:ARTRealtimeClosing withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeClosing withParams:[[ARTConnectionStateChangeParams alloc] init]]; break; } } @@ -518,35 +518,12 @@ - (BOOL)stats:(ARTStatsQuery *)query callback:(ARTPaginatedStatsCallback)callbac return [self.rest stats:query callback:callback error:errorPtr]; } -- (void)transition:(ARTRealtimeConnectionState)state withMetadata:(ARTConnectionStateChangeMetadata *)metadata { - ARTLogVerbose(self.logger, @"R:%p realtime state transitions to %tu - %@%@", self, state, ARTRealtimeConnectionStateToStr(state), metadata.retryAttempt ? [NSString stringWithFormat: @" (result of %@)", metadata.retryAttempt.id] : @""); - - ARTConnectionStateChange *stateChange = [[ARTConnectionStateChange alloc] initWithCurrent:state - previous:self.connection.state_nosync - event:(ARTRealtimeConnectionEvent)state - reason:metadata.errorInfo - retryIn:0 - retryAttempt:metadata.retryAttempt - resumed:metadata.resumed]; - [self.connection setState:state]; - [self.connection setErrorReason:metadata.errorInfo]; - - ARTEventListener *stateChangeEventListener = [self performTransitionWithStateChange:stateChange]; - - [_internalEventEmitter emit:[ARTEvent newWithConnectionEvent:(ARTRealtimeConnectionEvent)state] with:stateChange]; - - // stateChangeEventListener may be nil if we're in a failed state - if (stateChangeEventListener != nil) { - [stateChangeEventListener startTimer]; - } -} - -- (void)transitionToDisconnectedOrSuspendedWithMetadata:(ARTConnectionStateChangeMetadata *)metadata { +- (void)performTransitionToDisconnectedOrSuspendedWithParams:(ARTConnectionStateChangeParams *)params { if ([self isSuspendMode]) { - [self transition:ARTRealtimeSuspended withMetadata:metadata]; + [self performTransitionToState:ARTRealtimeSuspended withParams:params]; } else { - [self transition:ARTRealtimeDisconnected withMetadata:metadata]; + [self performTransitionToState:ARTRealtimeDisconnected withParams:params]; } } @@ -558,14 +535,8 @@ - (void)updateWithErrorInfo:(nullable ARTErrorInfo *)errorInfo { return; } - ARTConnectionStateChange *stateChange = [[ARTConnectionStateChange alloc] initWithCurrent:self.connection.state_nosync previous:self.connection.state_nosync event:ARTRealtimeConnectionEventUpdate reason:errorInfo retryIn:0]; - - ARTEventListener *stateChangeEventListener = [self performTransitionWithStateChange:stateChange]; - - // stateChangeEventListener may be nil if we're in a failed state - if (stateChangeEventListener != nil) { - [stateChangeEventListener startTimer]; - } + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToState:ARTRealtimeConnected withParams:params]; } - (void)handleNetworkIsReachable:(BOOL)reachable { @@ -583,7 +554,7 @@ - (void)handleNetworkIsReachable:(BOOL)reachable { } case ARTRealtimeDisconnected: case ARTRealtimeSuspended: - [self transition:ARTRealtimeConnecting withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeConnecting withParams:[[ARTConnectionStateChangeParams alloc] init]]; default: break; } @@ -593,8 +564,8 @@ - (void)handleNetworkIsReachable:(BOOL)reachable { case ARTRealtimeConnecting: case ARTRealtimeConnected: { ARTErrorInfo *unreachable = [ARTErrorInfo createWithCode:-1003 message:@"unreachable host"]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:unreachable]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:unreachable]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; break; } default: @@ -631,12 +602,26 @@ - (void)clearConnectionStateIfInactive { } } -- (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange *)stateChange { - ARTChannelStateChangeMetadata *channelStateChangeMetadata = nil; +- (void)performTransitionToState:(ARTRealtimeConnectionState)state withParams:(ARTConnectionStateChangeParams *)params { + ARTChannelStateChangeParams *channelStateChangeParams = nil; ARTEventListener *stateChangeEventListener = nil; + ARTLogVerbose(self.logger, @"R:%p realtime state transitions to %tu - %@%@", self, state, ARTRealtimeConnectionStateToStr(state), params.retryAttempt ? [NSString stringWithFormat: @" (result of %@)", params.retryAttempt.id] : @""); + + ARTRealtimeConnectionEvent event = state == self.connection.state_nosync ? ARTRealtimeConnectionEventUpdate : (ARTRealtimeConnectionEvent)state; + + ARTConnectionStateChange *stateChange = [[ARTConnectionStateChange alloc] initWithCurrent:state + previous:self.connection.state_nosync + event:event + reason:params.errorInfo + retryIn:0 + retryAttempt:params.retryAttempt]; + ARTLogDebug(self.logger, @"RT:%p realtime is transitioning from %tu - %@ to %tu - %@", self, stateChange.previous, ARTRealtimeConnectionStateToStr(stateChange.previous), stateChange.current, ARTRealtimeConnectionStateToStr(stateChange.current)); + [self.connection setState:state]; + [self.connection setErrorReason:params.errorInfo]; + [self.connectRetryState connectionWillTransitionToState:stateChange.current]; switch (stateChange.current) { @@ -667,7 +652,7 @@ - (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange [self stopIdleTimer]; [self setReachabilityActive:NO]; stateChangeEventListener = [self unlessStateChangesBefore:self.options.testOptions.realtimeRequestTimeout do:^{ - [self transition:ARTRealtimeClosed withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeClosed withParams:[[ARTConnectionStateChangeParams alloc] init]]; }]; [self.transport sendClose]; break; @@ -685,8 +670,7 @@ - (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange break; case ARTRealtimeFailed: { ARTStatus *const status = [ARTStatus state:ARTStateConnectionFailed info:stateChange.reason]; - channelStateChangeMetadata = [[ARTChannelStateChangeMetadata alloc] initWithState:status.state - errorInfo:status.errorInfo]; + channelStateChangeParams = [[ARTChannelStateChangeParams alloc] initWithState:status.state errorInfo:status.errorInfo]; [self abortAndReleaseTransport:status]; self.rest.prioritizedHost = nil; [self.auth cancelAuthorization:stateChange.reason]; @@ -713,9 +697,8 @@ - (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange [stateChange setRetryIn:retryDelay]; stateChangeEventListener = [self unlessStateChangesBefore:stateChange.retryIn do:^{ self->_connectionRetryFromDisconnectedListener = nil; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:nil - retryAttempt:retryAttempt]; - [self transition:ARTRealtimeConnecting withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:nil retryAttempt:retryAttempt]; + [self performTransitionToState:ARTRealtimeConnecting withParams:params]; }]; _connectionRetryFromDisconnectedListener = stateChangeEventListener; break; @@ -728,7 +711,7 @@ - (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange [stateChange setRetryIn:self.options.suspendedRetryTimeout]; stateChangeEventListener = [self unlessStateChangesBefore:stateChange.retryIn do:^{ self->_connectionRetryFromSuspendedListener = nil; - [self transition:ARTRealtimeConnecting withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeConnecting withParams:[[ARTConnectionStateChangeParams alloc] init]]; }]; _connectionRetryFromSuspendedListener = stateChangeEventListener; break; @@ -737,7 +720,7 @@ - (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange _fallbacks = nil; _connectionLostAt = nil; self.options.recover = nil; // RTN16k - [self resendPendingMessagesWithResumed:stateChange.resumed]; // RTN19a1 + [self resendPendingMessagesWithResumed:params.resumed]; // RTN19a1 [_connectedEventEmitter emit:nil with:nil]; break; } @@ -769,16 +752,16 @@ - (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange } } } else if (![self shouldQueueEvents]) { - if (!channelStateChangeMetadata) { + if (!channelStateChangeParams) { if (stateChange.reason) { - channelStateChangeMetadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateError - errorInfo:stateChange.reason]; + channelStateChangeParams = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateError + errorInfo:stateChange.reason]; } else { - channelStateChangeMetadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateError]; + channelStateChangeParams = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateError]; } } - ARTStatus *const channelStatus = [ARTStatus state:channelStateChangeMetadata.state info:channelStateChangeMetadata.errorInfo]; + ARTStatus *const channelStatus = [ARTStatus state:channelStateChangeParams.state info:channelStateChangeParams.errorInfo]; [self failQueuedMessages:channelStatus]; // Channels @@ -788,16 +771,16 @@ - (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange //do nothing. Closed state is coming. break; case ARTRealtimeClosed: { - ARTChannelStateChangeMetadata *const metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateOk]; - [channel detachChannel:metadata]; + ARTChannelStateChangeParams *const params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateOk]; + [channel detachChannel:params]; break; } case ARTRealtimeSuspended: { - [channel setSuspended:channelStateChangeMetadata]; + [channel setSuspended:channelStateChangeParams]; break; } case ARTRealtimeFailed: { - [channel setFailed:channelStateChangeMetadata]; + [channel setFailed:channelStateChangeParams]; break; } default: @@ -810,7 +793,12 @@ - (ARTEventListener *)performTransitionWithStateChange:(ARTConnectionStateChange [self performPendingAuthorizationWithState:stateChange.current error:stateChange.reason]; - return stateChangeEventListener; + [_internalEventEmitter emit:[ARTEvent newWithConnectionEvent:(ARTRealtimeConnectionEvent)state] with:stateChange]; + + // stateChangeEventListener may be nil if we're in a failed state + if (stateChangeEventListener != nil) { + [stateChangeEventListener startTimer]; + } } - (void)createAndConnectTransportWithConnectionResume:(BOOL)resume { @@ -879,8 +867,8 @@ - (void)onConnected:(ARTProtocolMessage *)message { } // Reattach all channels regardless resume success - RTN15c6, RTN15c7 for (ARTRealtimeChannelInternal *channel in self.channels.nosyncIterable) { - ARTAttachRequestMetadata *const metadata = [[ARTAttachRequestMetadata alloc] initWithReason:message.error]; - [channel reattachWithMetadata:metadata]; + ARTAttachRequestParams *const params = [[ARTAttachRequestParams alloc] initWithReason:message.error]; + [channel reattachWithParams:params]; } _resuming = false; } @@ -908,9 +896,9 @@ - (void)onConnected:(ARTProtocolMessage *)message { _lastActivity = [NSDate date]; [self setIdleTimer]; } - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:message.error]; - metadata.resumed = resumed; // RTN19a - [self transition:ARTRealtimeConnected withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:message.error]; + params.resumed = resumed; // RTN19a + [self performTransitionToState:ARTRealtimeConnected withParams:params]; break; } @@ -938,21 +926,21 @@ - (void)onDisconnected:(ARTProtocolMessage *)message { && !_renewingToken // If already reconnecting, give up. ) { if (![self.auth tokenIsRenewable]) { - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:error]; - [self transition:ARTRealtimeFailed withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:error]; + [self performTransitionToState:ARTRealtimeFailed withParams:params]; return; } - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:error]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:error]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; [self.connection setErrorReason:nil]; _renewingToken = true; - [self transition:ARTRealtimeConnecting withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeConnecting withParams:[[ARTConnectionStateChangeParams alloc] init]]; return; } - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:error]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:error]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } - (void)onClosed { @@ -962,7 +950,7 @@ - (void)onClosed { break; case ARTRealtimeClosing: [self.connection setId:nil]; - [self transition:ARTRealtimeClosed withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeClosed withParams:[[ARTConnectionStateChangeParams alloc] init]]; break; default: NSAssert(false, @"Invalid Realtime state transitioning to Closed: expected Closing or Closed, has %@", ARTRealtimeConnectionStateToStr(self.connection.state_nosync)); @@ -993,8 +981,8 @@ - (void)onError:(ARTProtocolMessage *)message { if (_renewingToken) { // Already retrying; give up. [self.connection setErrorReason:error]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:error]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:error]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; return; } [self transportReconnectWithRenewedToken]; @@ -1002,8 +990,8 @@ - (void)onError:(ARTProtocolMessage *)message { } [self.connection setId:nil]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:message.error]; - [self transition:ARTRealtimeFailed withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:message.error]; + [self performTransitionToState:ARTRealtimeFailed withParams:params]; } } @@ -1047,13 +1035,13 @@ - (void)onConnectionTimeOut { } switch (self.connection.state_nosync) { case ARTRealtimeConnected: { - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:error]; - [self transition:ARTRealtimeConnected withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:error]; + [self performTransitionToState:ARTRealtimeConnected withParams:params]; break; } default: { - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:error]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:error]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; break; } } @@ -1156,16 +1144,16 @@ - (void)handleTokenAuthError:(NSError *)error { if (error.code == ARTErrorIncompatibleCredentials) { // RSA15c ARTErrorInfo *const errorInfo = [ARTErrorInfo createFromNSError:error]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transition:ARTRealtimeFailed withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToState:ARTRealtimeFailed withParams:params]; } else if (self.options.authUrl || self.options.authCallback) { if (error.code == ARTErrorForbidden /* RSA4d */) { ARTErrorInfo *errorInfo = [ARTErrorInfo createWithCode:ARTErrorAuthConfiguredProviderFailure status:error.artStatusCode message:error.description]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transition:ARTRealtimeFailed withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToState:ARTRealtimeFailed withParams:params]; } else { ARTErrorInfo *errorInfo = [ARTErrorInfo createWithCode:ARTErrorAuthConfiguredProviderFailure status:ARTStateConnectionFailed message:error.description]; switch (self.connection.state_nosync) { @@ -1175,8 +1163,8 @@ - (void)handleTokenAuthError:(NSError *)error { break; default: { // RSA4c - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; break; } } @@ -1185,8 +1173,8 @@ - (void)handleTokenAuthError:(NSError *)error { else { // RSA4b ARTErrorInfo *const errorInfo = [ARTErrorInfo createFromNSError:error]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } } @@ -1207,7 +1195,7 @@ - (void)onChannelMessage:(ARTProtocolMessage *)message { } - (void)onSuspended { - [self transition:ARTRealtimeSuspended withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeSuspended withParams:[[ARTConnectionStateChangeParams alloc] init]]; } - (NSDate *)suspensionTime { @@ -1324,7 +1312,7 @@ - (void)send:(ARTProtocolMessage *)msg sentCallback:(ARTCallback)sentCallback ac [self send:msg reuseMsgSerial:NO sentCallback:sentCallback ackCallback:ackCallback]; } -- (void)resendPendingMessagesWithResumed:(BOOL)reuseMsgSerial { +- (void)resendPendingMessagesWithResumed:(BOOL)resumed { NSArray *pendingMessages = self.pendingMessages; if (pendingMessages.count > 0) { ARTLogDebug(self.logger, @"RT:%p resending messages waiting for acknowledgment", self); @@ -1332,7 +1320,7 @@ - (void)resendPendingMessagesWithResumed:(BOOL)reuseMsgSerial { self.pendingMessages = [NSMutableArray array]; for (ARTPendingMessage *pendingMessage in pendingMessages) { ARTProtocolMessage* pm = pendingMessage.msg; - [self send:pm reuseMsgSerial:reuseMsgSerial sentCallback:nil ackCallback:^(ARTStatus *status) { + [self send:pm reuseMsgSerial:resumed sentCallback:nil ackCallback:^(ARTStatus *status) { pendingMessage.ackCallback(status); }]; } @@ -1465,8 +1453,8 @@ - (BOOL)reconnectWithFallback { [self.rest internetIsUp:^void(BOOL isUp) { if (!isUp) { ARTErrorInfo *const errorInfo = [ARTErrorInfo createWithCode:0 message:@"no Internet connection"]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transition:ARTRealtimeDisconnected withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToState:ARTRealtimeDisconnected withParams:params]; return; } @@ -1509,8 +1497,8 @@ - (void)setIdleTimer { ARTLogError(self.logger, @"R:%p No activity seen from realtime in %f seconds; assuming connection has dropped", self, [[NSDate date] timeIntervalSinceDate:self->_lastActivity]); ARTErrorInfo *idleTimerExpired = [ARTErrorInfo createWithCode:ARTErrorDisconnected status:408 message:@"Idle timer expired"]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:idleTimerExpired]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:idleTimerExpired]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; }); } @@ -1600,10 +1588,10 @@ - (void)realtimeTransportClosed:(id)transport { if (self.connection.state_nosync == ARTRealtimeClosing) { // Close succeeded. Nothing more to do. - [self transition:ARTRealtimeClosed withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeClosed withParams:[[ARTConnectionStateChangeParams alloc] init]]; } else if (self.connection.state_nosync != ARTRealtimeClosed && self.connection.state_nosync != ARTRealtimeFailed) { // Unexpected closure; recover. - [self transitionToDisconnectedOrSuspendedWithMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToDisconnectedOrSuspendedWithParams:[[ARTConnectionStateChangeParams alloc] init]]; } } @@ -1614,11 +1602,11 @@ - (void)realtimeTransportDisconnected:(id)transport withEr } if (self.connection.state_nosync == ARTRealtimeClosing) { - [self transition:ARTRealtimeClosed withMetadata:[[ARTConnectionStateChangeMetadata alloc] init]]; + [self performTransitionToState:ARTRealtimeClosed withParams:[[ARTConnectionStateChangeParams alloc] init]]; } else { ARTErrorInfo *const errorInfo = [ARTErrorInfo createFromNSError:error.error]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } } @@ -1640,8 +1628,8 @@ - (void)realtimeTransportFailed:(id)transport withError:(A [self reconnectWithFallback]; } else { ARTErrorInfo *const errorInfo = [ARTErrorInfo createFromNSError:transportError.error]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transition:ARTRealtimeFailed withMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToState:ARTRealtimeFailed withParams:params]; } return; } else if (_fallbacks && [self reconnectWithFallback]) { @@ -1650,8 +1638,8 @@ - (void)realtimeTransportFailed:(id)transport withError:(A } ARTErrorInfo *const errorInfo = [ARTErrorInfo createFromNSError:transportError.error]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } - (void)realtimeTransportNeverConnected:(id)transport { @@ -1661,8 +1649,8 @@ - (void)realtimeTransportNeverConnected:(id)transport { } ARTErrorInfo *const errorInfo = [ARTErrorInfo createWithCode:ARTClientCodeErrorTransport message:@"Transport never connected"]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } - (void)realtimeTransportRefused:(id)transport withError:(ARTRealtimeTransportError *)error { @@ -1673,17 +1661,17 @@ - (void)realtimeTransportRefused:(id)transport withError:( if (error && error.type == ARTRealtimeTransportErrorTypeRefused) { ARTErrorInfo *const errorInfo = [ARTErrorInfo createWithCode:ARTClientCodeErrorTransport message:[NSString stringWithFormat:@"Connection refused using %@", error.url]]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } else if (error) { ARTErrorInfo *const errorInfo = [ARTErrorInfo createFromNSError:error.error]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } else { - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] init]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] init]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } } @@ -1694,8 +1682,8 @@ - (void)realtimeTransportTooBig:(id)transport { } ARTErrorInfo *const errorInfo = [ARTErrorInfo createWithCode:ARTClientCodeErrorTransport message:@"Transport too big"]; - ARTConnectionStateChangeMetadata *const metadata = [[ARTConnectionStateChangeMetadata alloc] initWithErrorInfo:errorInfo]; - [self transitionToDisconnectedOrSuspendedWithMetadata:metadata]; + ARTConnectionStateChangeParams *const params = [[ARTConnectionStateChangeParams alloc] initWithErrorInfo:errorInfo]; + [self performTransitionToDisconnectedOrSuspendedWithParams:params]; } - (void)realtimeTransportSetMsgSerial:(id)transport msgSerial:(int64_t)msgSerial { diff --git a/Source/ARTRealtimeChannel.m b/Source/ARTRealtimeChannel.m index c62d26244..50a1083fb 100644 --- a/Source/ARTRealtimeChannel.m +++ b/Source/ARTRealtimeChannel.m @@ -27,8 +27,8 @@ #import "ARTConnection+Private.h" #import "ARTRestChannels+Private.h" #import "ARTEventEmitter+Private.h" -#import "ARTChannelStateChangeMetadata.h" -#import "ARTAttachRequestMetadata.h" +#import "ARTChannelStateChangeParams.h" +#import "ARTAttachRequestParams.h" #import "ARTRetrySequence.h" #import "ARTBackoffRetryDelayCalculator.h" #import "ARTInternalLog.h" @@ -602,13 +602,13 @@ - (void)emit:(ARTChannelEvent)event with:(ARTChannelStateChange *)data { [self.internalEventEmitter emit:[ARTEvent newWithChannelEvent:event] with:data]; } -- (void)transition:(ARTRealtimeChannelState)state withMetadata:(ARTChannelStateChangeMetadata *)metadata { - ARTLogDebug(self.logger, @"RT:%p C:%p (%@) channel state transitions from %tu - %@ to %tu - %@%@", _realtime, self, self.name, self.state_nosync, ARTRealtimeChannelStateToStr(self.state_nosync), state, ARTRealtimeChannelStateToStr(state), metadata.retryAttempt ? [NSString stringWithFormat: @" (result of %@)", metadata.retryAttempt.id] : @""); - ARTChannelStateChange *stateChange = [[ARTChannelStateChange alloc] initWithCurrent:state previous:self.state_nosync event:(ARTChannelEvent)state reason:metadata.errorInfo resumed:NO retryAttempt:metadata.retryAttempt]; +- (void)performTransitionToState:(ARTRealtimeChannelState)state withParams:(ARTChannelStateChangeParams *)params { + ARTLogDebug(self.logger, @"RT:%p C:%p (%@) channel state transitions from %tu - %@ to %tu - %@%@", _realtime, self, self.name, self.state_nosync, ARTRealtimeChannelStateToStr(self.state_nosync), state, ARTRealtimeChannelStateToStr(state), params.retryAttempt ? [NSString stringWithFormat: @" (result of %@)", params.retryAttempt.id] : @""); + ARTChannelStateChange *stateChange = [[ARTChannelStateChange alloc] initWithCurrent:state previous:self.state_nosync event:(ARTChannelEvent)state reason:params.errorInfo resumed:NO retryAttempt:params.retryAttempt]; self.state = state; - if (metadata.storeErrorInfo) { - _errorReason = metadata.errorInfo; + if (params.storeErrorInfo) { + _errorReason = params.errorInfo; } [self.attachRetryState channelWillTransitionToState:state]; @@ -622,14 +622,12 @@ - (void)transition:(ARTRealtimeChannelState)state withMetadata:(ARTChannelStateC self.serial = nil; // RTP5a1 ARTRetryAttempt *const retryAttempt = [self.attachRetryState addRetryAttempt]; - [_attachedEventEmitter emit:nil with:metadata.errorInfo]; + [_attachedEventEmitter emit:nil with:params.errorInfo]; if (self.realtime.shouldSendEvents) { channelRetryListener = [self unlessStateChangesBefore:retryAttempt.delay do:^{ ARTLogDebug(self.logger, @"RT:%p C:%p (%@) reattach initiated by retry timeout, acting on retry attempt %@", self->_realtime, self, self.name, retryAttempt.id); - ARTAttachRequestMetadata *const attachMetadata = [[ARTAttachRequestMetadata alloc] initWithReason:nil - channelSerial:nil - retryAttempt:retryAttempt]; - [self reattachWithMetadata:attachMetadata]; + ARTAttachRequestParams *const attachParams = [[ARTAttachRequestParams alloc] initWithReason:nil channelSerial:nil retryAttempt:retryAttempt]; + [self reattachWithParams:attachParams]; }]; } break; @@ -639,14 +637,14 @@ - (void)transition:(ARTRealtimeChannelState)state withMetadata:(ARTChannelStateC break; case ARTRealtimeChannelDetached: self.serial = nil; // RTP5a1 - [self.presenceMap failsSync:metadata.errorInfo]; + [self.presenceMap failsSync:params.errorInfo]; break; case ARTRealtimeChannelFailed: self.serial = nil; // RTP5a1 self.attachResume = false; - [_attachedEventEmitter emit:nil with:metadata.errorInfo]; - [_detachedEventEmitter emit:nil with:metadata.errorInfo]; - [self.presenceMap failsSync:metadata.errorInfo]; + [_attachedEventEmitter emit:nil with:params.errorInfo]; + [_detachedEventEmitter emit:nil with:params.errorInfo]; + [self.presenceMap failsSync:params.errorInfo]; break; default: break; @@ -756,13 +754,13 @@ - (void)setAttached:(ARTProtocolMessage *)message { return; } - ARTChannelStateChangeMetadata *metadata; + ARTChannelStateChangeParams *params; if (message.error) { - metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateError errorInfo:message.error]; + params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateError errorInfo:message.error]; } else { - metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateOk]; + params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateOk]; } - [self transition:ARTRealtimeChannelAttached withMetadata:metadata]; + [self performTransitionToState:ARTRealtimeChannelAttached withParams:params]; [_attachedEventEmitter emit:nil with:nil]; [self.presence sendPendingPresence]; @@ -774,17 +772,17 @@ - (void)setDetached:(ARTProtocolMessage *)message { case ARTRealtimeChannelAttached: case ARTRealtimeChannelSuspended: { ARTLogDebug(self.logger, @"RT:%p C:%p (%@) reattach initiated by DETACHED message", _realtime, self, self.name); - ARTAttachRequestMetadata *const metadata = [[ARTAttachRequestMetadata alloc] initWithReason:message.error]; - [self reattachWithMetadata:metadata]; + ARTAttachRequestParams *const params = [[ARTAttachRequestParams alloc] initWithReason:message.error]; + [self reattachWithParams:params]; return; } case ARTRealtimeChannelAttaching: { ARTLogDebug(self.logger, @"RT:%p C:%p (%@) reattach initiated by DETACHED message but it is currently attaching", _realtime, self, self.name); const ARTState state = message.error ? ARTStateError : ARTStateOk; - ARTChannelStateChangeMetadata *const metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:state - errorInfo:message.error - storeErrorInfo:NO]; - [self setSuspended:metadata]; + ARTChannelStateChangeParams *const params = [[ARTChannelStateChangeParams alloc] initWithState:state + errorInfo:message.error + storeErrorInfo:NO]; + [self setSuspended:params]; return; } case ARTRealtimeChannelFailed: @@ -796,9 +794,8 @@ - (void)setDetached:(ARTProtocolMessage *)message { self.attachSerial = nil; ARTErrorInfo *errorInfo = message.error ? message.error : [ARTErrorInfo createWithCode:0 message:@"channel has detached"]; - ARTChannelStateChangeMetadata *const metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateNotAttached - errorInfo:errorInfo]; - [self detachChannel:metadata]; + ARTChannelStateChangeParams *const params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateNotAttached errorInfo:errorInfo]; + [self detachChannel:params]; [_detachedEventEmitter emit:nil with:nil]; } @@ -807,22 +804,22 @@ - (void)failPendingPresenceWithState:(ARTState)state info:(nullable ARTErrorInfo [self.presence failPendingPresence:status]; } -- (void)detachChannel:(ARTChannelStateChangeMetadata *)metadata { +- (void)detachChannel:(ARTChannelStateChangeParams *)params { if (self.state_nosync == ARTRealtimeChannelDetached) { return; } - [self failPendingPresenceWithState:metadata.state info:metadata.errorInfo]; - [self transition:ARTRealtimeChannelDetached withMetadata:metadata]; + [self failPendingPresenceWithState:params.state info:params.errorInfo]; + [self performTransitionToState:ARTRealtimeChannelDetached withParams:params]; } -- (void)setFailed:(ARTChannelStateChangeMetadata *)metadata { - [self failPendingPresenceWithState:metadata.state info:metadata.errorInfo]; - [self transition:ARTRealtimeChannelFailed withMetadata:metadata]; +- (void)setFailed:(ARTChannelStateChangeParams *)params { + [self failPendingPresenceWithState:params.state info:params.errorInfo]; + [self performTransitionToState:ARTRealtimeChannelFailed withParams:params]; } -- (void)setSuspended:(ARTChannelStateChangeMetadata *)metadata { - [self failPendingPresenceWithState:metadata.state info:metadata.errorInfo]; - [self transition:ARTRealtimeChannelSuspended withMetadata:metadata]; +- (void)setSuspended:(ARTChannelStateChangeParams *)params { + [self failPendingPresenceWithState:params.state info:params.errorInfo]; + [self performTransitionToState:ARTRealtimeChannelSuspended withParams:params]; } - (void)onMessage:(ARTProtocolMessage *)pm { @@ -956,9 +953,9 @@ - (void)broadcastPresence:(ARTPresenceMessage *)pm { } - (void)onError:(ARTProtocolMessage *)msg { - ARTChannelStateChangeMetadata *const metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateError + ARTChannelStateChangeParams *const params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateError errorInfo:msg.error]; - [self transition:ARTRealtimeChannelFailed withMetadata:metadata]; + [self performTransitionToState:ARTRealtimeChannelFailed withParams:params]; [self failPendingPresenceWithState:ARTStateError info:msg.error]; } @@ -993,20 +990,20 @@ - (void)_attach:(ARTCallback)callback { default: break; } - ARTAttachRequestMetadata *const metadata = [[ARTAttachRequestMetadata alloc] initWithReason:nil]; - [self internalAttach:callback metadata:metadata]; + ARTAttachRequestParams *const params = [[ARTAttachRequestParams alloc] initWithReason:nil]; + [self internalAttach:callback withParams:params]; } -- (void)reattachWithMetadata:(ARTAttachRequestMetadata *)metadata { +- (void)reattachWithParams:(ARTAttachRequestParams *)params { if ([self canBeReattached]) { ARTLogDebug(self.logger, @"RT:%p C:%p (%@) %@ and will reattach", _realtime, self, self.name, ARTRealtimeChannelStateToStr(self.state_nosync)); - [self internalAttach:nil metadata:metadata]; + [self internalAttach:nil withParams:params]; } else { ARTLogDebug(self.logger, @"RT:%p C:%p (%@) %@ should not reattach", _realtime, self, self.name, ARTRealtimeChannelStateToStr(self.state_nosync)); } } -- (void)internalAttach:(ARTCallback)callback metadata:(ARTAttachRequestMetadata *)metadata { +- (void)internalAttach:(ARTCallback)callback withParams:(ARTAttachRequestParams *)params { switch (self.state_nosync) { case ARTRealtimeChannelDetaching: { ARTLogDebug(self.logger, @"RT:%p C:%p (%@) attach after the completion of Detaching", _realtime, self, self.name); @@ -1029,12 +1026,9 @@ - (void)internalAttach:(ARTCallback)callback metadata:(ARTAttachRequestMetadata if (callback) [_attachedEventEmitter once:callback]; // Set state: Attaching - const ARTState stateChangeMetadataState = metadata.reason ? ARTStateError : ARTStateOk; - ARTChannelStateChangeMetadata *const stateChangeMetadata = [[ARTChannelStateChangeMetadata alloc] initWithState:stateChangeMetadataState - errorInfo:metadata.reason - storeErrorInfo:NO - retryAttempt:metadata.retryAttempt]; - [self transition:ARTRealtimeChannelAttaching withMetadata:stateChangeMetadata]; + const ARTState state = params.reason ? ARTStateError : ARTStateOk; + ARTChannelStateChangeParams *const stateChangeParams = [[ARTChannelStateChangeParams alloc] initWithState:state errorInfo:params.reason storeErrorInfo:NO retryAttempt:params.retryAttempt]; + [self performTransitionToState:ARTRealtimeChannelAttaching withParams:stateChangeParams]; [self attachAfterChecks:callback]; } @@ -1058,9 +1052,9 @@ - (void)attachAfterChecks:(ARTCallback)callback { [[self unlessStateChangesBefore:self.realtime.options.testOptions.realtimeRequestTimeout do:^{ // Timeout ARTErrorInfo *errorInfo = [ARTErrorInfo createWithCode:ARTStateAttachTimedOut message:@"attach timed out"]; - ARTChannelStateChangeMetadata *const metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateAttachTimedOut - errorInfo:errorInfo]; - [self setSuspended:metadata]; + ARTChannelStateChangeParams *const params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateAttachTimedOut + errorInfo:errorInfo]; + [self setSuspended:params]; }] startTimer]; } ackCallback:nil]; } @@ -1106,8 +1100,8 @@ - (void)_detach:(ARTCallback)callback { return; case ARTRealtimeChannelSuspended: { ARTLogDebug(self.logger, @"RT:%p C:%p (%@) transitions immediately to the detached", _realtime, self, self.name); - ARTChannelStateChangeMetadata *const metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateOk]; - [self transition:ARTRealtimeChannelDetached withMetadata:metadata]; + ARTChannelStateChangeParams *const params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateOk]; + [self performTransitionToState:ARTRealtimeChannelDetached withParams:params]; if (callback) callback(nil); return; } @@ -1127,8 +1121,8 @@ - (void)_detach:(ARTCallback)callback { if (callback) [_detachedEventEmitter once:callback]; // Set state: Detaching - ARTChannelStateChangeMetadata *const metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateOk]; - [self transition:ARTRealtimeChannelDetaching withMetadata:metadata]; + ARTChannelStateChangeParams *const params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateOk]; + [self performTransitionToState:ARTRealtimeChannelDetaching withParams:params]; [self detachAfterChecks:callback]; } @@ -1146,9 +1140,9 @@ - (void)detachAfterChecks:(ARTCallback)callback { } // Timeout ARTErrorInfo *errorInfo = [ARTErrorInfo createWithCode:ARTStateDetachTimedOut message:@"detach timed out"]; - ARTChannelStateChangeMetadata *const metadata = [[ARTChannelStateChangeMetadata alloc] initWithState:ARTStateAttachTimedOut - errorInfo:errorInfo]; - [self transition:ARTRealtimeChannelAttached withMetadata:metadata]; + ARTChannelStateChangeParams *const params = [[ARTChannelStateChangeParams alloc] initWithState:ARTStateAttachTimedOut + errorInfo:errorInfo]; + [self performTransitionToState:ARTRealtimeChannelAttached withParams:params]; [self->_detachedEventEmitter emit:nil with:errorInfo]; }] startTimer]; @@ -1195,10 +1189,10 @@ - (void)startDecodeFailureRecoveryWithErrorInfo:(ARTErrorInfo *)error { ARTLogWarn(self.logger, @"R:%p C:%p (%@) starting delta decode failure recovery process", _realtime, self, self.name); _decodeFailureRecoveryInProgress = true; - ARTAttachRequestMetadata *const metadata = [[ARTAttachRequestMetadata alloc] initWithReason:error]; + ARTAttachRequestParams *const params = [[ARTAttachRequestParams alloc] initWithReason:error]; [self internalAttach:^(ARTErrorInfo *e) { self->_decodeFailureRecoveryInProgress = false; - } metadata:metadata]; + } withParams:params]; } #pragma mark - ARTPresenceMapDelegate @@ -1279,8 +1273,8 @@ - (void)setOptions_nosync:(ARTRealtimeChannelOptions *_Nullable)options callback case ARTRealtimeChannelAttached: case ARTRealtimeChannelAttaching: { ARTLogDebug(self.logger, @"RT:%p C:%p (%@) set options in %@ state", _realtime, self, self.name, ARTRealtimeChannelStateToStr(self.state_nosync)); - ARTAttachRequestMetadata *const metadata = [[ARTAttachRequestMetadata alloc] initWithReason:nil]; - [self internalAttach:callback metadata:metadata]; + ARTAttachRequestParams *const params = [[ARTAttachRequestParams alloc] initWithReason:nil]; + [self internalAttach:callback withParams:params]; break; } default: diff --git a/Source/ARTTypes.m b/Source/ARTTypes.m index b9a35e08b..990d544a0 100644 --- a/Source/ARTTypes.m +++ b/Source/ARTTypes.m @@ -45,10 +45,10 @@ - (instancetype)initWithCurrent:(ARTRealtimeConnectionState)current previous:(AR } - (instancetype)initWithCurrent:(ARTRealtimeConnectionState)current previous:(ARTRealtimeConnectionState)previous event:(ARTRealtimeConnectionEvent)event reason:(ARTErrorInfo *)reason retryIn:(NSTimeInterval)retryIn { - return [self initWithCurrent:current previous:previous event:event reason:reason retryIn:retryIn retryAttempt:nil resumed:NO]; + return [self initWithCurrent:current previous:previous event:event reason:reason retryIn:retryIn retryAttempt:nil]; } -- (instancetype)initWithCurrent:(ARTRealtimeConnectionState)current previous:(ARTRealtimeConnectionState)previous event:(ARTRealtimeConnectionEvent)event reason:(ARTErrorInfo *)reason retryIn:(NSTimeInterval)retryIn retryAttempt:(ARTRetryAttempt *)retryAttempt resumed:(BOOL)resumed { +- (instancetype)initWithCurrent:(ARTRealtimeConnectionState)current previous:(ARTRealtimeConnectionState)previous event:(ARTRealtimeConnectionEvent)event reason:(ARTErrorInfo *)reason retryIn:(NSTimeInterval)retryIn retryAttempt:(ARTRetryAttempt *)retryAttempt { self = [self init]; if (self) { _current = current; @@ -57,7 +57,6 @@ - (instancetype)initWithCurrent:(ARTRealtimeConnectionState)current previous:(AR _reason = reason; _retryIn = retryIn; _retryAttempt = retryAttempt; - _resumed = resumed; } return self; } diff --git a/Source/Ably.modulemap b/Source/Ably.modulemap index c76454eb1..2d9bda1d4 100644 --- a/Source/Ably.modulemap +++ b/Source/Ably.modulemap @@ -85,9 +85,9 @@ framework module Ably { header "ARTRetryDelayCalculator.h" header "ARTBackoffRetryDelayCalculator.h" header "ARTClientOptions+TestConfiguration.h" - header "ARTConnectionStateChangeMetadata.h" - header "ARTChannelStateChangeMetadata.h" - header "ARTAttachRequestMetadata.h" + header "ARTConnectionStateChangeParams.h" + header "ARTChannelStateChangeParams.h" + header "ARTAttachRequestParams.h" header "ARTRetrySequence.h" header "ARTTypes+Private.h" header "ARTTestClientOptions.h" diff --git a/Source/PrivateHeaders/Ably/ARTAttachRequestMetadata.h b/Source/PrivateHeaders/Ably/ARTAttachRequestParams.h similarity index 75% rename from Source/PrivateHeaders/Ably/ARTAttachRequestMetadata.h rename to Source/PrivateHeaders/Ably/ARTAttachRequestParams.h index de584a34a..2fe6bf65f 100644 --- a/Source/PrivateHeaders/Ably/ARTAttachRequestMetadata.h +++ b/Source/PrivateHeaders/Ably/ARTAttachRequestParams.h @@ -6,10 +6,10 @@ NS_ASSUME_NONNULL_BEGIN /** - Provides metadata for a request to perform an operation that may ultimately call `ARTChannelRealtimeInternal`’s `internalAttach:callback:` method. + Provides parameters for a request to perform an operation that may ultimately call `ARTChannelRealtimeInternal`’s `internalAttach:callback:` method. */ -NS_SWIFT_NAME(AttachRequestMetadata) -@interface ARTAttachRequestMetadata: NSObject +NS_SWIFT_NAME(AttachRequestParams) +@interface ARTAttachRequestParams: NSObject /** Information about the error that triggered this attach request, if any. @@ -26,7 +26,7 @@ NS_SWIFT_NAME(AttachRequestMetadata) - (instancetype)init NS_UNAVAILABLE; /** - Creates an `ARTAttachRequestMetadata` instance with the given `reason`, whose `channelSerial` is `nil`. + Creates an `ARTAttachRequestParams` instance with the given `reason`, whose `channelSerial` is `nil`. */ - (instancetype)initWithReason:(nullable ARTErrorInfo *)reason; diff --git a/Source/PrivateHeaders/Ably/ARTChannelStateChangeMetadata.h b/Source/PrivateHeaders/Ably/ARTChannelStateChangeParams.h similarity index 75% rename from Source/PrivateHeaders/Ably/ARTChannelStateChangeMetadata.h rename to Source/PrivateHeaders/Ably/ARTChannelStateChangeParams.h index 49358d5e2..d5a24128a 100644 --- a/Source/PrivateHeaders/Ably/ARTChannelStateChangeMetadata.h +++ b/Source/PrivateHeaders/Ably/ARTChannelStateChangeParams.h @@ -7,12 +7,12 @@ NS_ASSUME_NONNULL_BEGIN /** - Provides metadata for a request to perform an operation that may cause an `ARTRealtimeChannelInternal` instance to emit a connection state change. + Provides parameters for a request to perform an operation that may cause an `ARTRealtimeChannelInternal` instance to emit a connection state change. `ARTRealtimeChannelInternal` will incorporate some of this data into the `ARTChannelStateChange` object that it emits as a result of the connection state change. */ -NS_SWIFT_NAME(ChannelStateChangeMetadata) -@interface ARTChannelStateChangeMetadata: NSObject +NS_SWIFT_NAME(ChannelStateChangeParams) +@interface ARTChannelStateChangeParams: NSObject /** A state that some operations will use when failing pending presence operations. @@ -34,12 +34,12 @@ NS_SWIFT_NAME(ChannelStateChangeMetadata) - (instancetype)init NS_UNAVAILABLE; /** - Creates an `ARTChannelStateChangeMetadata` instance whose `errorInfo` is `nil`, and whose `storeErrorInfo` is `NO`. + Creates an `ARTChannelStateChangeParams` instance whose `errorInfo` is `nil`, and whose `storeErrorInfo` is `NO`. */ - (instancetype)initWithState:(ARTState)state; /** - Creates an `ARTChannelStateChangeMetadata` instance with the given `errorInfo`, whose `storeErrorInfo` is `YES`. + Creates an `ARTChannelStateChangeParams` instance with the given `errorInfo`, whose `storeErrorInfo` is `YES`. */ - (instancetype)initWithState:(ARTState)state errorInfo:(nullable ARTErrorInfo *)errorInfo; diff --git a/Source/PrivateHeaders/Ably/ARTConnectionStateChangeMetadata.h b/Source/PrivateHeaders/Ably/ARTConnectionStateChangeParams.h similarity index 71% rename from Source/PrivateHeaders/Ably/ARTConnectionStateChangeMetadata.h rename to Source/PrivateHeaders/Ably/ARTConnectionStateChangeParams.h index e4124cc79..c38654d2b 100644 --- a/Source/PrivateHeaders/Ably/ARTConnectionStateChangeMetadata.h +++ b/Source/PrivateHeaders/Ably/ARTConnectionStateChangeParams.h @@ -6,12 +6,12 @@ NS_ASSUME_NONNULL_BEGIN /** - Provides metadata for a request to perform an operation that may cause an `ARTRealtimeInternal` instance to emit a connection state change. + Provides parameters for a request to perform an operation that may cause an `ARTRealtimeInternal` instance to emit a connection state change. `ARTRealtimeInternal` will incorporate this data into the `ARTConnectionStateChange` object that it emits as a result of the connection state change. */ -NS_SWIFT_NAME(ConnectionStateChangeMetadata) -@interface ARTConnectionStateChangeMetadata: NSObject +NS_SWIFT_NAME(ConnectionStateChangeParams) +@interface ARTConnectionStateChangeParams: NSObject /** Information about the error that triggered this state change, if any. @@ -23,7 +23,7 @@ NS_SWIFT_NAME(ConnectionStateChangeMetadata) @property (assign, nonatomic) BOOL resumed; /** - Creates an `ARTConnectionStateChangeMetadata` instance whose `errorInfo` is `nil`. + Creates an `ARTConnectionStateChangeParams` instance whose `errorInfo` is `nil`. */ - (instancetype)init; diff --git a/Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h b/Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h index 17b52a031..a8b848857 100644 --- a/Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h +++ b/Source/PrivateHeaders/Ably/ARTRealtimeChannel+Private.h @@ -13,8 +13,8 @@ @class ARTProtocolMessage; @class ARTRealtimePresenceInternal; -@class ARTChannelStateChangeMetadata; -@class ARTAttachRequestMetadata; +@class ARTChannelStateChangeParams; +@class ARTAttachRequestParams; NS_ASSUME_NONNULL_BEGIN @@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN - (bool)isLastChannelSerial:(NSString *)channelSerial; -- (void)reattachWithMetadata:(ARTAttachRequestMetadata *)metadata; +- (void)reattachWithParams:(ARTAttachRequestParams *)params; - (void)_attach:(nullable ARTCallback)callback; - (void)_detach:(nullable ARTCallback)callback; @@ -65,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN @interface ARTRealtimeChannelInternal (Private) -- (void)transition:(ARTRealtimeChannelState)state withMetadata:(ARTChannelStateChangeMetadata *)metadata; +- (void)performTransitionToState:(ARTRealtimeChannelState)state withParams:(ARTChannelStateChangeParams *)params; - (void)onChannelMessage:(ARTProtocolMessage *)message; - (void)publishProtocolMessage:(ARTProtocolMessage *)pm callback:(ARTStatusCallback)cb; @@ -78,12 +78,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)onSync:(ARTProtocolMessage *)message; - (void)onError:(ARTProtocolMessage *)error; -- (void)setSuspended:(ARTChannelStateChangeMetadata *)metadata; -- (void)setFailed:(ARTChannelStateChangeMetadata *)metadata; +- (void)setSuspended:(ARTChannelStateChangeParams *)params; +- (void)setFailed:(ARTChannelStateChangeParams *)params; - (void)throwOnDisconnectedOrFailed; - (void)broadcastPresence:(ARTPresenceMessage *)pm; -- (void)detachChannel:(ARTChannelStateChangeMetadata *)metadata; +- (void)detachChannel:(ARTChannelStateChangeParams *)params; - (void)sync; - (void)sync:(nullable ARTCallback)callback; diff --git a/Source/PrivateHeaders/Ably/ARTTypes+Private.h b/Source/PrivateHeaders/Ably/ARTTypes+Private.h index 72c753b52..ba0cd2561 100644 --- a/Source/PrivateHeaders/Ably/ARTTypes+Private.h +++ b/Source/PrivateHeaders/Ably/ARTTypes+Private.h @@ -15,18 +15,12 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, readonly, nullable) ARTRetryAttempt *retryAttempt; -/** - * Indicates whether the connection was resumed. - */ -@property (assign, nonatomic) BOOL resumed; - - (instancetype)initWithCurrent:(ARTRealtimeConnectionState)current previous:(ARTRealtimeConnectionState)previous event:(ARTRealtimeConnectionEvent)event reason:(nullable ARTErrorInfo *)reason retryIn:(NSTimeInterval)retryIn - retryAttempt:(nullable ARTRetryAttempt *)retryAttempt - resumed:(BOOL)resumed; + retryAttempt:(nullable ARTRetryAttempt *)retryAttempt; @end diff --git a/Test/Tests/RealtimeClientConnectionTests.swift b/Test/Tests/RealtimeClientConnectionTests.swift index 129725578..16e9a3be1 100644 --- a/Test/Tests/RealtimeClientConnectionTests.swift +++ b/Test/Tests/RealtimeClientConnectionTests.swift @@ -5129,6 +5129,7 @@ class RealtimeClientConnectionTests: XCTestCase { fail("Reason error is nil"); done(); return } XCTAssertEqual(error.code, 1234) + XCTAssertEqual(client.connection.errorReason?.code, 1234) XCTAssertEqual(client.connection.state, ARTRealtimeConnectionState.connected) XCTAssertEqual(stateChange.current, ARTRealtimeConnectionState.connected) XCTAssertEqual(stateChange.current, stateChange.previous) @@ -5139,8 +5140,6 @@ class RealtimeClientConnectionTests: XCTestCase { connectedMessageWithError.error = ARTErrorInfo.create(withCode: 1234, message: "fabricated error") client.internal.transport?.receive(connectedMessageWithError) } - - XCTAssertNil(client.connection.errorReason) } // https://github.com/ably/ably-cocoa/issues/454 diff --git a/Test/Tests/RealtimeClientTests.swift b/Test/Tests/RealtimeClientTests.swift index f65891763..91cc43519 100644 --- a/Test/Tests/RealtimeClientTests.swift +++ b/Test/Tests/RealtimeClientTests.swift @@ -200,6 +200,7 @@ class RealtimeClientTests: XCTestCase { func test__019__RealtimeClient__options__url_should_contains_transport_params() throws { let test = Test() let options = try AblyTests.commonAppSetup(for: test) + options.autoConnect = false options.transportParams = [ "tpBool": .init(bool: true), "tpInt": .init(number: .init(value: 12)), @@ -211,7 +212,7 @@ class RealtimeClientTests: XCTestCase { let client = ARTRealtime(options: options) defer { client.dispose(); client.close() } - waitUntil(timeout: testTimeout.multiplied(by: 2)) { done in + waitUntil(timeout: testTimeout) { done in client.connection.once(.connecting) { _ in guard let webSocketTransport = client.internal.transport as? ARTWebSocketTransport else { fail("Transport should be of type ARTWebSocketTransport"); done()