File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed
Sources/LiveViewNative/Coordinators Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -266,15 +266,7 @@ public class LiveSessionCoordinator<R: RootRegistry>: ObservableObject {
266
266
}
267
267
}
268
268
269
- let liveChannel = try await self . liveSocket!. joinLiveviewChannel (
270
- . some( [
271
- " _format " : . str( string: LiveSessionParameters . platform) ,
272
- " _interface " : . object( object: LiveSessionParameters . platformParams)
273
- ] ) ,
274
- nil
275
- )
276
-
277
- self . navigationPath. last!. coordinator. join ( liveChannel)
269
+ try await self . joinLiveViewChannel ( )
278
270
279
271
self . state = . connected
280
272
@@ -328,6 +320,18 @@ public class LiveSessionCoordinator<R: RootRegistry>: ObservableObject {
328
320
329
321
}
330
322
}
323
+
324
+ func joinLiveViewChannel( ) async throws {
325
+ let liveChannel = try await self . liveSocket!. joinLiveviewChannel (
326
+ . some( [
327
+ " _format " : . str( string: LiveSessionParameters . platform) ,
328
+ " _interface " : . object( object: LiveSessionParameters . platformParams)
329
+ ] ) ,
330
+ nil
331
+ )
332
+
333
+ self . navigationPath. last? . coordinator. join ( liveChannel)
334
+ }
331
335
332
336
private func disconnect( preserveNavigationPath: Bool = false ) async {
333
337
do {
Original file line number Diff line number Diff line change @@ -270,6 +270,13 @@ public class LiveViewCoordinator<R: RootRegistry>: ObservableObject {
270
270
guard !Task. isCancelled else { return }
271
271
do {
272
272
switch event. event {
273
+ case . phoenix( phoenix: . error) :
274
+ logger. error ( " encountered error in reply - channel reconnecting " ) ;
275
+ if let liveChannel {
276
+ let channel = liveChannel. channel ( )
277
+ try await channel. shutdown ( )
278
+ }
279
+ try await session. joinLiveViewChannel ( )
273
280
case . user( user: " diff " ) :
274
281
switch event. payload {
275
282
case let . jsonPayload( json) :
@@ -342,6 +349,7 @@ public class LiveViewCoordinator<R: RootRegistry>: ObservableObject {
342
349
}
343
350
344
351
func join( _ liveChannel: LiveViewNativeCore . LiveChannel ) {
352
+
345
353
self . liveChannel = liveChannel
346
354
let channel = liveChannel. channel ( )
347
355
self . channel = channel
You can’t perform that action at this time.
0 commit comments