feat(multiplayer): add P2P online matches with live camera verification#99
feat(multiplayer): add P2P online matches with live camera verification#99BenedictHomuth wants to merge 24 commits intomainfrom
Conversation
|
I was just thinking: maybe we should split online and local play into two separate routes @BenedictHomuth |
Eliminated the redundant <Title> element from MatchSettingsForm and retained it in the lobby page to avoid duplicate section headers. This improves UI clarity by ensuring the match settings title appears only once.
Displays a notification when no webcam is detected during profile creation. Added localized error messages for both English and German.
This comment was marked as outdated.
This comment was marked as outdated.
Replaced hardcoded English text in the multiplayer lobby page with localized strings. Added new translation keys for descriptions, placeholders, and button labels in both English and German locale files.
|
@BenedictHomuth Its possible to connect to a random string (eg "ddd"). The UI will return a lobby with "Connect to Lobby" |
Replaced hardcoded English strings in the multiplayer lobby page with translation keys. Added missing translation entries for both English and German locales to support new UI labels and actions.
|
Addressed, both the invalid lobby id and the infinite loop of the webcam |
|
So the invalid room id input is fix 👍 But it still crashes when I use two instances on my PC |
|
It might be that the webcam creates a race condition, when both instances "start" the multiplayer game. Here both try to access the camera at the exact same time. As Windows is to my knowledge very restrictive on this (e.g., only one process can use the camera at a time), this might be the issue here. If you want to test this, I recommend you to explicitly deny one of the instances access to the camera/mic and check. |
|
I actually tried both times without a webcam connected. Maybe thats the problem |
Changed the screenshot button in StepThree to use the new 'profile:takeScreenshot' translation key. Added 'takeScreenshot' entries to both English and German locale files for profile.
Merge main into feature/ai-dart-detection
🔄 Proposal: Migrate Multiplayer from PeerJS to ColyseusAs we consider scaling our multiplayer features, we should evaluate moving from our current Peer-to-Peer (PeerJS) architecture to an Authoritative Client-Server (Colyseus) architecture. Here is a breakdown of the pros, cons, and major architectural shifts this migration would entail. 🌟 Pros of Switching to Colyseus
|
|
What's your opinion @BenedictHomuth? Worth a try or should we stay with the P2P solution. I'm not really sure 😅 |
This PR transforms the application into a networked multiplayer platform while strictly maintaining the privacy and offline integrity of the original local mode. It introduces Peer-to-Peer (WebRTC) connectivity for remote darts matches and enhances profile customization with real-time video features.
✨ Key Features
🏠 Online Lobby System
INIT_GAMEsignal broadcasts the configuration, automatically redirecting all guests from the Lobby to the active Game Board with synchronized settings.📹 Camera Verification (Full Mesh)
📸 Webcam Avatar Capture
🔄 Real-Time Synchronization
THROW_DART,UNDO_THROW,NEXT_TURN,TOGGLE_MULTIPLIER) is broadcast as a lightweight JSON payload. The local reducer applies these actions deterministically, ensuring scores and statistics are identical on all screens.🔒 Privacy & Offline Isolation
We have implemented a strict Lazy Initialization pattern to guarantee that "Local Mode" remains 100% air-gapped from any networking logic:
nullin the global context.new Peer()) occurs only inside thehostGame()andjoinGame()triggers. The webcam for avatars only activates upon explicit user request within the modal.if (state.matchMode === 'online'). In a local match, the network stack is completely bypassed.🛡️ Technical Implementation
VideoStreamlogic into a reusable component (renderer/components/media/VideoStream.tsx).forwardRefin theVideoStreamcomponent to allow parent components (like the Profile Creator) to access the underlying<video>element for frame capture and canvas processing.MultiplayerContextmanages the complex lifecycle of WebRTC connections, media streams, and data channels.renderer/tests/multiplayer/gameSync.test.ts) that simulates network traffic to verify state machine synchronization.en) and German (de) localization for all new components (30+ new translation keys).