feat(ws): rewrite websocket flow using Actix actors instead of manual… #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR rewrites the entire WebSocket flow to use Actix actors instead of the previous manual handler-based implementation.
The old approach mixed state management, routing, and message broadcasting inside a single handler, which caused issues with lifetimes, shared mutability, and concurrency.
The new architecture fully adopts the Actix actor model:
Changes:
Introduced a WsClient actor to encapsulate per-connection state and handle incoming WebSocket frames.
Added a RoomManager actor responsible for room creation, membership tracking, and broadcasting messages to connected clients.
Replaced manual message routing with typed Actix messages (Join, Leave, RoomMessage, etc.).
Removed lifetime-dependent logic and moved all mutable shared state into Actor mailboxes.
Improved isolation between clients — no shared mutable state, no need for mutexes.
Ensured safe, concurrent communication using Actix’s actor scheduling and message passing.
Benefits:
Cleaner separation of concerns (client vs room management).
No lifetime errors from shared references.
Proper concurrency — actors never block the event loop.
Easier to extend (adding rooms, private messages, game logic, etc.)
More idiomatic Rust + Actix implementation.