Play2P is a browser-based peer-to-peer game console. Two players open the same URL; their browsers connect via WebRTC and play. No game server. No account. No relay.
The site is static. After page load, traffic flows between the two players, plus short STUN queries during the handshake.
The remaining slides cover the handshake in order.
Player 1 clicks New Game. The script runs locally; the site is not contacted again.
The page creates an RTCPeerConnection, opens a data channel on it, and generates a session description: the offer.
The offer is a JSON-encoded RTCSessionDescription:
Typical size: 2–4 KB.
"offer" from the host, "answer" from the guest.srflx is the public address discovered via STUN.During ICE gathering, the browser queries public STUN servers for its public IP and port. Each response becomes an a=candidate line of type srflx.
stun:stun.l.google.com:19302stun:stun.cloudflare.com:3478STUN does not relay traffic. One UDP query, one response. Out of the path once the data channel opens.
Player 1 sends the code to Player 2 through any messaging channel: SMS, email, Discord. The channel does not need to be encrypted.
Routing data, not a credential. Network candidates, a DTLS fingerprint, the data channel description. No account or device identity.
Player 2 opens the same URL, clicks Join Game, and pastes the offer.
Player 2's browser parses the offer, creates its own RTCPeerConnection, and generates an SDP answer. STUN runs again to gather Player 2's own public address.
Same fields. type is now "answer"; candidates describe Player 2's network:
Player 2 returns the answer to Player 1 over the same channel.
Player 1 pastes the answer and clicks Start match. The browser applies it as the remote description.
Each browser probes candidate pairs until it finds one reachable in both directions. The result is typically a direct path, including across NATs.
The RTCDataChannel opens with DTLS-SRTP encryption. Game traffic flows between the two browsers. The site and STUN servers leave the path. Encryption keys never leave the two endpoints.
The library, the games, and this page live in one repository.