Skip to content

Commit 18570cb

Browse files
Merge pull request #337 from pusher/tech/sources-reorganisation
Source files reorganisation & access level optimisations
2 parents 386c424 + 7bda8cc commit 18570cb

29 files changed

+489
-406
lines changed

PusherSwift.xcodeproj/project.pbxproj

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
33BB997A1D21230100B25C2A /* PusherConnectionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33BB99641D21226C00B25C2A /* PusherConnectionTests.swift */; };
2929
33BB997B1D21230100B25C2A /* PusherIncomingEventHandlingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33BB99651D21226C00B25C2A /* PusherIncomingEventHandlingTests.swift */; };
3030
33BB997C1D21230100B25C2A /* PusherTopLevelAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33BB99661D21226C00B25C2A /* PusherTopLevelAPITests.swift */; };
31-
33C1FD6F1D81BFC300921AD7 /* ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33C1FD6E1D81BFC300921AD7 /* ObjectiveC.swift */; };
31+
33C1FD6F1D81BFC300921AD7 /* OCPusherHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33C1FD6E1D81BFC300921AD7 /* OCPusherHost.swift */; };
3232
33C40CB91C1DFC9C008A54E3 /* PusherSwift.h in Headers */ = {isa = PBXBuildFile; fileRef = 33831CD61A9CFFF200B124F1 /* PusherSwift.h */; settings = {ATTRIBUTES = (Public, ); }; };
3333
53140355250A8F7600F3D7BF /* PusherChannelsProtocolCloseCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53140354250A8F7600F3D7BF /* PusherChannelsProtocolCloseCode.swift */; };
3434
535AC2A9256EABB100598820 /* PusherDecryptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 73D8A2012435E686001FDE05 /* PusherDecryptor.swift */; };
@@ -37,6 +37,23 @@
3737
535AC2C9256EAE4600598820 /* PrivateEncryptedChannelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D32DBA192445BCD60064DA56 /* PrivateEncryptedChannelTests.swift */; };
3838
539D9AFC2507F67300B5765A /* PusherLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539D9AFB2507F67300B5765A /* PusherLogger.swift */; };
3939
539D9AFE2507F68400B5765A /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 539D9AFD2507F68400B5765A /* Constants.swift */; };
40+
53A9AFBB25CDAD84008B1736 /* PusherChannelType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFBA25CDAD84008B1736 /* PusherChannelType.swift */; };
41+
53A9AFBF25CDADFC008B1736 /* QueuedClientEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFBE25CDADFC008B1736 /* QueuedClientEvent.swift */; };
42+
53A9AFC525CDAE18008B1736 /* EventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFC425CDAE18008B1736 /* EventHandler.swift */; };
43+
53A9AFC925CDAFAC008B1736 /* ConnectionState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFC825CDAFAC008B1736 /* ConnectionState.swift */; };
44+
53A9AFCD25CDAFD8008B1736 /* PusherEventError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFCC25CDAFD8008B1736 /* PusherEventError.swift */; };
45+
53A9AFD125CDB037008B1736 /* PusherHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFD025CDB037008B1736 /* PusherHost.swift */; };
46+
53A9AFD725CDB054008B1736 /* AuthMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFD625CDB054008B1736 /* AuthMethod.swift */; };
47+
53A9AFDF25CDB2F0008B1736 /* PusherPresenceChannelMember.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFDE25CDB2F0008B1736 /* PusherPresenceChannelMember.swift */; };
48+
53A9AFE325D13D1F008B1736 /* PusherAuth.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFE225D13D1F008B1736 /* PusherAuth.swift */; };
49+
53A9AFE925D13E4A008B1736 /* PusherAuthError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFE825D13E4A008B1736 /* PusherAuthError.swift */; };
50+
53A9AFEF25D13FB4008B1736 /* Pusher+ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFEE25D13FB4008B1736 /* Pusher+ObjectiveC.swift */; };
51+
53A9AFF325D13FE5008B1736 /* PusherConnection+ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFF225D13FE5008B1736 /* PusherConnection+ObjectiveC.swift */; };
52+
53A9AFF725D14004008B1736 /* PusherClientOptions+ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFF625D14004008B1736 /* PusherClientOptions+ObjectiveC.swift */; };
53+
53A9AFFB25D1402F008B1736 /* PusherHost+ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFFA25D1402F008B1736 /* PusherHost+ObjectiveC.swift */; };
54+
53A9AFFF25D1404D008B1736 /* AuthMethod+ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9AFFE25D1404D008B1736 /* AuthMethod+ObjectiveC.swift */; };
55+
53A9B00325D1407E008B1736 /* PusherError+ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9B00225D1407E008B1736 /* PusherError+ObjectiveC.swift */; };
56+
53A9B00925D140B8008B1736 /* OCAuthMethod.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53A9B00825D140B8008B1736 /* OCAuthMethod.swift */; };
4057
736E53F5242A378B0052CC1B /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736E53F3242A35D90052CC1B /* String+Extensions.swift */; };
4158
736E53F7242A45AC0052CC1B /* XCTest+Assertions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 736E53F6242A45AC0052CC1B /* XCTest+Assertions.swift */; };
4259
E2498293231E612700CFBBD6 /* PusherError.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2498292231E612700CFBBD6 /* PusherError.swift */; };
@@ -90,10 +107,27 @@
90107
33BB99651D21226C00B25C2A /* PusherIncomingEventHandlingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PusherIncomingEventHandlingTests.swift; sourceTree = "<group>"; };
91108
33BB99661D21226C00B25C2A /* PusherTopLevelAPITests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PusherTopLevelAPITests.swift; sourceTree = "<group>"; };
92109
33BB99671D21226C00B25C2A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ../Tests/Info.plist; sourceTree = "<group>"; };
93-
33C1FD6E1D81BFC300921AD7 /* ObjectiveC.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ObjectiveC.swift; sourceTree = "<group>"; };
110+
33C1FD6E1D81BFC300921AD7 /* OCPusherHost.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OCPusherHost.swift; sourceTree = "<group>"; };
94111
53140354250A8F7600F3D7BF /* PusherChannelsProtocolCloseCode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PusherChannelsProtocolCloseCode.swift; sourceTree = "<group>"; };
95112
539D9AFB2507F67300B5765A /* PusherLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PusherLogger.swift; sourceTree = "<group>"; };
96113
539D9AFD2507F68400B5765A /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
114+
53A9AFBA25CDAD84008B1736 /* PusherChannelType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PusherChannelType.swift; sourceTree = "<group>"; };
115+
53A9AFBE25CDADFC008B1736 /* QueuedClientEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QueuedClientEvent.swift; sourceTree = "<group>"; };
116+
53A9AFC425CDAE18008B1736 /* EventHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EventHandler.swift; sourceTree = "<group>"; };
117+
53A9AFC825CDAFAC008B1736 /* ConnectionState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionState.swift; sourceTree = "<group>"; };
118+
53A9AFCC25CDAFD8008B1736 /* PusherEventError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PusherEventError.swift; sourceTree = "<group>"; };
119+
53A9AFD025CDB037008B1736 /* PusherHost.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PusherHost.swift; sourceTree = "<group>"; };
120+
53A9AFD625CDB054008B1736 /* AuthMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthMethod.swift; sourceTree = "<group>"; };
121+
53A9AFDE25CDB2F0008B1736 /* PusherPresenceChannelMember.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PusherPresenceChannelMember.swift; sourceTree = "<group>"; };
122+
53A9AFE225D13D1F008B1736 /* PusherAuth.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PusherAuth.swift; sourceTree = "<group>"; };
123+
53A9AFE825D13E4A008B1736 /* PusherAuthError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PusherAuthError.swift; sourceTree = "<group>"; };
124+
53A9AFEE25D13FB4008B1736 /* Pusher+ObjectiveC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Pusher+ObjectiveC.swift"; sourceTree = "<group>"; };
125+
53A9AFF225D13FE5008B1736 /* PusherConnection+ObjectiveC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PusherConnection+ObjectiveC.swift"; sourceTree = "<group>"; };
126+
53A9AFF625D14004008B1736 /* PusherClientOptions+ObjectiveC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PusherClientOptions+ObjectiveC.swift"; sourceTree = "<group>"; };
127+
53A9AFFA25D1402F008B1736 /* PusherHost+ObjectiveC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PusherHost+ObjectiveC.swift"; sourceTree = "<group>"; };
128+
53A9AFFE25D1404D008B1736 /* AuthMethod+ObjectiveC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AuthMethod+ObjectiveC.swift"; sourceTree = "<group>"; };
129+
53A9B00225D1407E008B1736 /* PusherError+ObjectiveC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PusherError+ObjectiveC.swift"; sourceTree = "<group>"; };
130+
53A9B00825D140B8008B1736 /* OCAuthMethod.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OCAuthMethod.swift; sourceTree = "<group>"; };
97131
736E53F3242A35D90052CC1B /* String+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = "<group>"; };
98132
736E53F6242A45AC0052CC1B /* XCTest+Assertions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCTest+Assertions.swift"; sourceTree = "<group>"; };
99133
73D8A2012435E686001FDE05 /* PusherDecryptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PusherDecryptor.swift; sourceTree = "<group>"; };
@@ -200,15 +234,25 @@
200234
5333ACFA24F8036B006E8DF0 /* Models */ = {
201235
isa = PBXGroup;
202236
children = (
237+
53A9AFD625CDB054008B1736 /* AuthMethod.swift */,
238+
53A9AFC825CDAFAC008B1736 /* ConnectionState.swift */,
203239
539D9AFD2507F68400B5765A /* Constants.swift */,
240+
53A9AFC425CDAE18008B1736 /* EventHandler.swift */,
241+
53A9AFE225D13D1F008B1736 /* PusherAuth.swift */,
242+
53A9AFE825D13E4A008B1736 /* PusherAuthError.swift */,
204243
3384C1B81CAECD9C00F10796 /* PusherChannel.swift */,
244+
53A9AFBA25CDAD84008B1736 /* PusherChannelType.swift */,
205245
3389F5711CAEDDF300563F49 /* PusherChannels.swift */,
206246
53140354250A8F7600F3D7BF /* PusherChannelsProtocolCloseCode.swift */,
207247
3389F5791CAEDEC800563F49 /* PusherClientOptions.swift */,
208248
E2498292231E612700CFBBD6 /* PusherError.swift */,
209249
E2B21F06243F5B860049A35B /* PusherEvent.swift */,
250+
53A9AFCC25CDAFD8008B1736 /* PusherEventError.swift */,
210251
3389F5751CAEDE2800563F49 /* PusherGlobalChannel.swift */,
252+
53A9AFD025CDB037008B1736 /* PusherHost.swift */,
211253
3389F56D1CAEDDD800563F49 /* PusherPresenceChannel.swift */,
254+
53A9AFBE25CDADFC008B1736 /* QueuedClientEvent.swift */,
255+
53A9AFDE25CDB2F0008B1736 /* PusherPresenceChannelMember.swift */,
212256
);
213257
path = Models;
214258
sourceTree = "<group>";
@@ -236,7 +280,14 @@
236280
5333ACFD24F80FCD006E8DF0 /* ObjC */ = {
237281
isa = PBXGroup;
238282
children = (
239-
33C1FD6E1D81BFC300921AD7 /* ObjectiveC.swift */,
283+
53A9AFFE25D1404D008B1736 /* AuthMethod+ObjectiveC.swift */,
284+
53A9B00825D140B8008B1736 /* OCAuthMethod.swift */,
285+
33C1FD6E1D81BFC300921AD7 /* OCPusherHost.swift */,
286+
53A9AFEE25D13FB4008B1736 /* Pusher+ObjectiveC.swift */,
287+
53A9AFF625D14004008B1736 /* PusherClientOptions+ObjectiveC.swift */,
288+
53A9AFF225D13FE5008B1736 /* PusherConnection+ObjectiveC.swift */,
289+
53A9B00225D1407E008B1736 /* PusherError+ObjectiveC.swift */,
290+
53A9AFFA25D1402F008B1736 /* PusherHost+ObjectiveC.swift */,
240291
);
241292
path = ObjC;
242293
sourceTree = "<group>";
@@ -511,24 +562,41 @@
511562
E26B8606244A079E00735172 /* PusherEncryptionHelpers.swift in Sources */,
512563
539D9AFE2507F68400B5765A /* Constants.swift in Sources */,
513564
E2B21F0A243F5BB50049A35B /* PusherConnection.swift in Sources */,
565+
53A9AFBB25CDAD84008B1736 /* PusherChannelType.swift in Sources */,
566+
53A9AFC525CDAE18008B1736 /* EventHandler.swift in Sources */,
567+
53A9AFF725D14004008B1736 /* PusherClientOptions+ObjectiveC.swift in Sources */,
568+
53A9AFEF25D13FB4008B1736 /* Pusher+ObjectiveC.swift in Sources */,
514569
33BA54201D9035BD00CD853B /* PusherDelegate.swift in Sources */,
570+
53A9AFD125CDB037008B1736 /* PusherHost.swift in Sources */,
571+
53A9AFFB25D1402F008B1736 /* PusherHost+ObjectiveC.swift in Sources */,
515572
E2498293231E612700CFBBD6 /* PusherError.swift in Sources */,
516573
E2F40FA523ED782B00985C40 /* PusherCrypto.swift in Sources */,
574+
53A9AFBF25CDADFC008B1736 /* QueuedClientEvent.swift in Sources */,
575+
53A9AFFF25D1404D008B1736 /* AuthMethod+ObjectiveC.swift in Sources */,
517576
E2B21F0D243F5DC10049A35B /* PusherWebsocketDelegate.swift in Sources */,
577+
53A9AFC925CDAFAC008B1736 /* ConnectionState.swift in Sources */,
578+
53A9AFE925D13E4A008B1736 /* PusherAuthError.swift in Sources */,
518579
330D7A6D1CAEDA750032FF2C /* PusherChannel.swift in Sources */,
519580
3390D1E81F054D1E00E1944D /* Authorizer.swift in Sources */,
520581
3389F5721CAEDDF300563F49 /* PusherChannels.swift in Sources */,
521582
E2CFE43122D79CA7004187C3 /* PusherParser.swift in Sources */,
583+
53A9AFCD25CDAFD8008B1736 /* PusherEventError.swift in Sources */,
522584
3389F5761CAEDE2800563F49 /* PusherGlobalChannel.swift in Sources */,
523585
E2B21F01243F5B1E0049A35B /* PusherEventFactory.swift in Sources */,
586+
53A9AFE325D13D1F008B1736 /* PusherAuth.swift in Sources */,
587+
53A9B00925D140B8008B1736 /* OCAuthMethod.swift in Sources */,
524588
3389F57A1CAEDEC800563F49 /* PusherClientOptions.swift in Sources */,
525589
E2B21F07243F5B860049A35B /* PusherEvent.swift in Sources */,
590+
53A9AFF325D13FE5008B1736 /* PusherConnection+ObjectiveC.swift in Sources */,
526591
539D9AFC2507F67300B5765A /* PusherLogger.swift in Sources */,
592+
53A9AFDF25CDB2F0008B1736 /* PusherPresenceChannelMember.swift in Sources */,
527593
E2B21EFF243F5B1E0049A35B /* PusherEventQueue.swift in Sources */,
594+
53A9B00325D1407E008B1736 /* PusherError+ObjectiveC.swift in Sources */,
528595
3389F56E1CAEDDD800563F49 /* PusherPresenceChannel.swift in Sources */,
529-
33C1FD6F1D81BFC300921AD7 /* ObjectiveC.swift in Sources */,
596+
33C1FD6F1D81BFC300921AD7 /* OCPusherHost.swift in Sources */,
530597
535AC2A9256EABB100598820 /* PusherDecryptor.swift in Sources */,
531598
3390D1E61F054D0400E1944D /* AuthRequestBuilderProtocol.swift in Sources */,
599+
53A9AFD725CDB054008B1736 /* AuthMethod.swift in Sources */,
532600
330D7A6A1CAEDA6C0032FF2C /* PusherSwift.swift in Sources */,
533601
);
534602
runOnlyForDeploymentPostprocessing = 0;

Sources/Extensions/PusherWebsocketDelegate.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ extension PusherConnection: WebSocketConnectionDelegate {
117117
`PusherChannelsProtocolCloseCode.ReconnectionStrategy`.
118118
- Parameter closeCode: The closure code received by the WebSocket connection.
119119
*/
120-
internal func attemptReconnect(closeCode: NWProtocolWebSocket.CloseCode = .protocolCode(.normalClosure)) {
120+
func attemptReconnect(closeCode: NWProtocolWebSocket.CloseCode = .protocolCode(.normalClosure)) {
121121
guard connectionState != .connected else {
122122
return
123123
}
@@ -161,7 +161,7 @@ extension PusherConnection: WebSocketConnectionDelegate {
161161
/// Returns a `TimeInterval` appropriate for a reconnection attempt after some delay.
162162
/// - Parameter strategy: The reconnection strategy for the reconnection attempt.
163163
/// - Returns: An appropriate `TimeInterval`. (0.0 if `strategy == .reconnectImmediately`).
164-
internal func reconnectionAttemptTimeInterval(strategy: PusherChannelsProtocolCloseCode.ReconnectionStrategy) -> TimeInterval {
164+
func reconnectionAttemptTimeInterval(strategy: PusherChannelsProtocolCloseCode.ReconnectionStrategy) -> TimeInterval {
165165
if case .reconnectImmediately = strategy {
166166
return 0.0
167167
}
@@ -174,7 +174,7 @@ extension PusherConnection: WebSocketConnectionDelegate {
174174

175175
/// Logs the websocket reconnection attempt.
176176
/// - Parameter strategy: The reconnection strategy for the reconnection attempt.
177-
internal func logReconnectionAttempt(strategy: PusherChannelsProtocolCloseCode.ReconnectionStrategy) {
177+
func logReconnectionAttempt(strategy: PusherChannelsProtocolCloseCode.ReconnectionStrategy) {
178178

179179
var context = "(attempt \(reconnectAttempts + 1))"
180180
var loggingEvent = PusherLogger.LoggingEvent.attemptReconnectionImmediately
@@ -197,7 +197,7 @@ extension PusherConnection: WebSocketConnectionDelegate {
197197
/// - Parameters:
198198
/// - closeCode: The closure code for the websocket connection.
199199
/// - reason: Optional further information on the connection closure.
200-
internal func logDisconnection(closeCode: NWProtocolWebSocket.CloseCode, reason: Data?) {
200+
func logDisconnection(closeCode: NWProtocolWebSocket.CloseCode, reason: Data?) {
201201
var rawCode: UInt16!
202202
switch closeCode {
203203
case .protocolCode(let definedCode):

Sources/Helpers/PusherEventFactory.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,3 @@ struct PusherConcreteEventFactory: PusherEventFactory {
4545
// MARK: - Types
4646

4747
typealias PusherEventPayload = [String: Any]
48-
49-
// MARK: - Error handling
50-
51-
enum PusherEventError: Error {
52-
53-
case invalidFormat
54-
case invalidDecryptionKey
55-
case invalidEncryptedData
56-
}

0 commit comments

Comments
 (0)