Skip to content

Refactor RankedMatch to accept WebSocket as prop#125

Merged
Azuretier merged 1 commit intomainfrom
claude/fix-websocket-ranked-match-IZ3wF
Feb 8, 2026
Merged

Refactor RankedMatch to accept WebSocket as prop#125
Azuretier merged 1 commit intomainfrom
claude/fix-websocket-ranked-match-IZ3wF

Conversation

@Azuretier
Copy link
Owner

Summary

Refactored the RankedMatch component to accept WebSocket connection and related state as props from the parent MultiplayerGame component, rather than managing its own connection lifecycle. This simplifies the component and centralizes connection management.

Key Changes

  • Moved connection management to parent: MultiplayerGame now passes ws, connectionStatus, and playerId as props to RankedMatch
  • Removed server-side matchmaking: Eliminated the queue-based ranked matchmaking flow (queue_ranked, cancel_ranked, search timer, etc.)
  • Simplified to AI-only matches: The component now only supports client-side AI matches that start immediately without server coordination
  • Removed connection lifecycle code: Deleted WebSocket connection setup, reconnection logic, and related state management from RankedMatch
  • Removed status bar: Eliminated the connection status display UI since connection is now managed externally
  • Removed searching phase: Deleted the entire "searching for opponent" UI and related timer logic
  • Simplified message handling: Removed most server message handlers (ranked_queued, ranked_match_found, etc.) since matches are now AI-only
  • Updated AI game integration: Modified AI board update callbacks to use the passed WebSocket reference and opponent ID from props

Implementation Details

  • The component now uses a useRef to keep the WebSocket prop in sync with effects
  • AI matches auto-start countdown immediately after the "found" phase
  • Relay messages for AI garbage/game-over are intercepted at the WebSocket send level to prevent sending to server
  • Cleanup on unmount properly stops any running AI game
  • The component is now stateless regarding connection concerns, making it easier to test and reuse

https://claude.ai/code/session_01LURnwvyMCMH3jxsucseWiU

…, start AI match directly

- RankedMatch now receives ws, connectionStatus, and playerId as props
  from MultiplayerGame instead of creating its own WebSocket connection
- Removed duplicate "Online" connection status indicator from RankedMatch
  (only the parent MultiplayerGame status bar is shown)
- FIND MATCH now starts an AI match immediately client-side without
  waiting for server matchmaking queue (no 8-second delay)
- Relay messages during AI match are routed locally instead of to the
  server, while non-relay messages (pong, etc.) still pass through

https://claude.ai/code/session_01LURnwvyMCMH3jxsucseWiU
@vercel
Copy link
Contributor

vercel bot commented Feb 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
azuretier.net Ready Ready Preview, Comment Feb 8, 2026 4:58am

Request Review

@Azuretier Azuretier merged commit 5cb9c3b into main Feb 8, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants