Skip to content

Commit

Permalink
Add reason to discontinuity event logging
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrence-forooghian committed Nov 25, 2024
1 parent 4adb981 commit 9c87a98
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/AblyChat/RoomLifecycleManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -448,12 +448,12 @@ internal actor DefaultRoomLifecycleManager<Contributor: RoomLifecycleContributor

if hasOperationInProgress {
// CHA-RL4a3
logger.log(message: "Recording pending discontinuity event for contributor \(contributor)", level: .info)
logger.log(message: "Recording pending discontinuity event \(reason) for contributor \(contributor)", level: .info)

contributorAnnotations[contributor].pendingDiscontinuityEvents.append(reason)
} else {
// CHA-RL4a4
logger.log(message: "Emitting discontinuity event for contributor \(contributor)", level: .info)
logger.log(message: "Emitting discontinuity event \(reason) for contributor \(contributor)", level: .info)

await contributor.emitDiscontinuity(reason)
}
Expand All @@ -464,13 +464,14 @@ internal actor DefaultRoomLifecycleManager<Contributor: RoomLifecycleContributor
if hasOperationInProgress {
if !stateChange.resumed, hadAlreadyAttached {
// CHA-RL4b1
logger.log(message: "Recording pending discontinuity event for contributor \(contributor)", level: .info)

guard let reason = stateChange.reason else {
// TODO: Decide the right thing to do here (https://github.com/ably-labs/ably-chat-swift/issues/74)
preconditionFailure("Non-initial ATTACHED state change with resumed == false should have a reason")
}

logger.log(message: "Recording pending discontinuity event \(reason) for contributor \(contributor)", level: .info)

contributorAnnotations[contributor].pendingDiscontinuityEvents.append(reason)
}
} else {
Expand Down

0 comments on commit 9c87a98

Please sign in to comment.