Skip to content

Add explicit listener lifecycle management #52

Open
jonasew opened this issue Apr 3, 2026 · 0 comments
Open

Add explicit listener lifecycle management #52

jonasew opened this issue Apr 3, 2026 · 0 comments
Assignees

Comments

@jonasew
Copy link
Member

jonasew commented Apr 3, 2026

Problem: Network listeners are started but not clearly stopped, which can lead to duplicated callbacks or stale subscriptions (not tested yet, so is not confirmed yet). Basically, when the player goes from one screen to the next, the network listener from the previous game is still active

Target files:

  • GameNetworkHandler.java
  • GameScreen.java:439
  • AndroidFirebase.java

Refactor:

  • Add stop/dispose methods in the networking layer.
  • Store references to every ValueEventListener/ChildEventListener in AndroidFirebase and unregister them when screen exits.
  • Call networkHandler.stop() from both hide and dispose.

Acceptance criteria:

  • Re-entering a match screen does not duplicate opponent move events.
  • No listener callbacks arrive after leaving the match.
@francinv francinv self-assigned this Apr 4, 2026
francinv pushed a commit that referenced this issue Apr 6, 2026
#52, #53)

- Track all Firebase listeners via cleanup runnables in AndroidFirebase
- Add removeAllListeners() to FirebaseAPI interface
- Add stop() to GameNetworkHandler, called from GameScreen hide/dispose
- Fix confirmSetup: propagate errors to onError callback instead of
  silently calling onSuccess on failure paths
- Update SetupFlowController to pass error callback to confirmSetup
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants