Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset online clients when stream is disconnected #181

Merged
merged 8 commits into from
May 17, 2024
Merged

Conversation

7hong13
Copy link
Contributor

@7hong13 7hong13 commented May 16, 2024

What this PR does / why we need it?

Any background context you want to provide?

What are the relevant tickets?

Fixes #

Checklist

  • Added relevant tests or not required
  • Didn't break anything

@7hong13 7hong13 self-assigned this May 16, 2024
@7hong13 7hong13 added this to the 0.4.19 milestone May 16, 2024
@7hong13 7hong13 added the enhancement 🌟 New feature or request label May 16, 2024
@7hong13 7hong13 requested review from skhugh and hackerwins May 16, 2024 12:02
@7hong13 7hong13 marked this pull request as ready for review May 16, 2024 12:02
@@ -18,9 +18,9 @@ public class Presences private constructor(

public operator fun minus(actorID: ActorID): Presences = (map - actorID).asPresences()

override fun hashCode(): Int = map.hashCode()

override fun equals(other: Any?): Boolean = map == (other as? Presences)?.map
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it to ensure that document.publishPresenceEvent() is properly invoked whenever a new value is emitted to document.presences.

}
val streamJob = launch(start = CoroutineStart.UNDISPATCHED) {
val channel = stream.responseChannel()
var retry = 0
while (!stream.isReceiveClosed() && !channel.isClosedForReceive) {
val receiveResult = channel.receiveCatching()
receiveResult.onSuccess {
attachment.document.publishEvent(StreamConnectionChange.Connected)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we need this line?
if the stream fails then succeed on retry, users would not receive the connected state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed it. fixed in 4f46596

@7hong13
Copy link
Contributor Author

7hong13 commented May 17, 2024

Some tests are failing in the CI, but I checked they're working fine with the real server. I'll investigate these failing tests after merging.

@7hong13 7hong13 merged commit 4bd5474 into main May 17, 2024
4 of 6 checks passed
@7hong13 7hong13 deleted the reset_online_clients branch May 17, 2024 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🌟 New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants