@@ -11,20 +11,20 @@ extension PusherConnection: WebSocketConnectionDelegate {
11
11
- parameter string: The message received over the websocket
12
12
*/
13
13
public func webSocketDidReceiveMessage( connection: WebSocketConnection , string: String ) {
14
- PusherLogger . shared. debug ( for: . receivedMessage, context: string)
14
+ Logger . shared. debug ( for: . receivedMessage, context: string)
15
15
16
- guard let payload = PusherParser . getPusherEventJSON ( from: string) ,
16
+ guard let payload = EventParser . getPusherEventJSON ( from: string) ,
17
17
let event = payload [ Constants . JSONKeys. event] as? String
18
18
else {
19
- PusherLogger . shared. debug ( for: . unableToHandleIncomingMessage,
20
- context: string)
19
+ Logger . shared. debug ( for: . unableToHandleIncomingMessage,
20
+ context: string)
21
21
return
22
22
}
23
23
24
24
if event == Constants . Events. Pusher. error {
25
25
guard let error = PusherError ( jsonObject: payload) else {
26
- PusherLogger . shared. debug ( for: . unableToHandleIncomingError,
27
- context: string)
26
+ Logger . shared. debug ( for: . unableToHandleIncomingError,
27
+ context: string)
28
28
return
29
29
}
30
30
self . handleError ( error: error)
@@ -36,7 +36,7 @@ extension PusherConnection: WebSocketConnectionDelegate {
36
36
/// Delegate method called when a pong is received over a websocket
37
37
/// - Parameter connection: The websocket that has received the pong
38
38
public func webSocketDidReceivePong( connection: WebSocketConnection ) {
39
- PusherLogger . shared. debug ( for: . pongReceived)
39
+ Logger . shared. debug ( for: . pongReceived)
40
40
resetActivityTimeoutTimer ( )
41
41
}
42
42
@@ -64,7 +64,7 @@ extension PusherConnection: WebSocketConnectionDelegate {
64
64
updateConnectionState ( to: . disconnected)
65
65
66
66
guard !intentionalDisconnect else {
67
- PusherLogger . shared. debug ( for: . intentionalDisconnection)
67
+ Logger . shared. debug ( for: . intentionalDisconnection)
68
68
return
69
69
}
70
70
@@ -82,7 +82,7 @@ extension PusherConnection: WebSocketConnectionDelegate {
82
82
}
83
83
84
84
guard reconnectAttemptsMax == nil || reconnectAttempts < reconnectAttemptsMax! else {
85
- PusherLogger . shared. debug ( for: . maxReconnectAttemptsLimitReached)
85
+ Logger . shared. debug ( for: . maxReconnectAttemptsLimitReached)
86
86
return
87
87
}
88
88
@@ -91,9 +91,9 @@ extension PusherConnection: WebSocketConnectionDelegate {
91
91
92
92
public func webSocketViabilityDidChange( connection: WebSocketConnection , isViable: Bool ) {
93
93
if isViable {
94
- PusherLogger . shared. debug ( for: . networkConnectionViable)
94
+ Logger . shared. debug ( for: . networkConnectionViable)
95
95
} else {
96
- PusherLogger . shared. debug ( for: . networkConnectionUnviable)
96
+ Logger . shared. debug ( for: . networkConnectionUnviable)
97
97
}
98
98
}
99
99
@@ -103,8 +103,8 @@ extension PusherConnection: WebSocketConnectionDelegate {
103
103
updateConnectionState ( to: . reconnecting)
104
104
105
105
case . failure( let error) :
106
- PusherLogger . shared. debug ( for: . errorReceived,
107
- context: """
106
+ Logger . shared. debug ( for: . errorReceived,
107
+ context: """
108
108
Path migration error: \( error. debugDescription)
109
109
""" )
110
110
}
@@ -128,9 +128,9 @@ extension PusherConnection: WebSocketConnectionDelegate {
128
128
129
129
// Reconnect attempt according to Pusher Channels Protocol close code (if present).
130
130
// (Otherwise, the default behavior is to attempt reconnection after backing off).
131
- var channelsCloseCode : PusherChannelsProtocolCloseCode ?
131
+ var channelsCloseCode : ChannelsProtocolCloseCode ?
132
132
if case let . privateCode( code) = closeCode {
133
- channelsCloseCode = PusherChannelsProtocolCloseCode ( rawValue: code)
133
+ channelsCloseCode = ChannelsProtocolCloseCode ( rawValue: code)
134
134
}
135
135
let strategy = channelsCloseCode? . reconnectionStrategy ?? . reconnectAfterBackingOff
136
136
@@ -161,7 +161,7 @@ extension PusherConnection: WebSocketConnectionDelegate {
161
161
/// Returns a `TimeInterval` appropriate for a reconnection attempt after some delay.
162
162
/// - Parameter strategy: The reconnection strategy for the reconnection attempt.
163
163
/// - Returns: An appropriate `TimeInterval`. (0.0 if `strategy == .reconnectImmediately`).
164
- func reconnectionAttemptTimeInterval( strategy: PusherChannelsProtocolCloseCode . ReconnectionStrategy ) -> TimeInterval {
164
+ func reconnectionAttemptTimeInterval( strategy: ChannelsProtocolCloseCode . ReconnectionStrategy ) -> TimeInterval {
165
165
if case . reconnectImmediately = strategy {
166
166
return 0.0
167
167
}
@@ -174,10 +174,10 @@ extension PusherConnection: WebSocketConnectionDelegate {
174
174
175
175
/// Logs the websocket reconnection attempt.
176
176
/// - Parameter strategy: The reconnection strategy for the reconnection attempt.
177
- func logReconnectionAttempt( strategy: PusherChannelsProtocolCloseCode . ReconnectionStrategy ) {
177
+ func logReconnectionAttempt( strategy: ChannelsProtocolCloseCode . ReconnectionStrategy ) {
178
178
179
179
var context = " (attempt \( reconnectAttempts + 1 ) ) "
180
- var loggingEvent = PusherLogger . LoggingEvent. attemptReconnectionImmediately
180
+ var loggingEvent = Logger . LoggingEvent. attemptReconnectionImmediately
181
181
182
182
if reconnectAttemptsMax != nil {
183
183
context. insert ( contentsOf: " of \( reconnectAttemptsMax!) " , at: context. index ( before: context. endIndex) )
@@ -189,8 +189,8 @@ extension PusherConnection: WebSocketConnectionDelegate {
189
189
context = " \( timeInterval) seconds " + context
190
190
}
191
191
192
- PusherLogger . shared. debug ( for: loggingEvent,
193
- context: context)
192
+ Logger . shared. debug ( for: loggingEvent,
193
+ context: context)
194
194
}
195
195
196
196
/// Logs the websocket disconnection event.
@@ -218,8 +218,8 @@ extension PusherConnection: WebSocketConnectionDelegate {
218
218
closeMessage += " Reason: \( reasonString) . "
219
219
}
220
220
221
- PusherLogger . shared. debug ( for: . disconnectionWithoutError,
222
- context: closeMessage)
221
+ Logger . shared. debug ( for: . disconnectionWithoutError,
222
+ context: closeMessage)
223
223
}
224
224
225
225
/**
@@ -236,8 +236,8 @@ extension PusherConnection: WebSocketConnectionDelegate {
236
236
}
237
237
238
238
public func webSocketDidReceiveError( connection: WebSocketConnection , error: NWError ) {
239
- PusherLogger . shared. debug ( for: . errorReceived,
240
- context: """
239
+ Logger . shared. debug ( for: . errorReceived,
240
+ context: """
241
241
Error: \( error. debugDescription)
242
242
""" )
243
243
}
0 commit comments