-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
enhancementNew feature or requestNew feature or request
Description
✨ Networking — Implement P2P Handshake & Messaging
Description
We need to implement the initial P2P networking layer for Multibonk.
This includes the ability for two game clients to:
- Discover and establish a direct peer-to-peer connection (with NAT traversal if possible).
- Exchange simple messages reliably (e.g., ping/pong).
- Fallback to relay (TURN) if direct connection fails.
This is the foundation for the multiplayer system, later features such as state synchronization and input replication will depend on this.
Scope
- Create a
NetworkManager(or equivalent) module to handle P2P connections. - Support WebRTC DataChannels for initial implementation (abstracted for future replacement if needed).
- Implement a handshake protocol:
- Exchange peer IDs.
- Confirm readiness before sending game data.
- Basic messaging API:
sendMessage(type, payload)for outgoing messages.onMessage(type, callback)for incoming messages.
- Add minimal logging for debugging connections.
Acceptance Criteria
- Two local game instances can connect directly (when network permits).
- Connection attempt retries at least 3 times before failing.
- If direct connection fails, a fallback relay (TURN) server can be used (configurable).
- Successful handshake confirms both peers are ready (log confirmation).
- Ability to send a simple
pingmessage and receive apongresponse. - Network errors are logged with clear messages (no silent failures).
- Unit tests for handshake and message serialization/deserialization.
Definition of Done
- Code merged into
mainbehind a feature flag (if applicable). - README or
docs/networking.mdupdated with connection flow and developer setup. - CI passes with new networking tests.
Additional Notes
- Future tasks will build on this to add state replication and client prediction.
- The relay server config can initially be a simple TURN server URL/env variable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request