# EdgePlay — complete AI integration guide > Turn an existing game into multiplayer with a player-owned master peer. Preserve its engine, assets and offline single-player mode. Complete the conversion end-to-end, including actual game code, invite UI and tests. Do not stop at a scaffold. First inspect the project's engine/version, language, export target, input, simulation and renderer. Ask only for information the project cannot reveal. Godot runs both natively AND on the Web: do not infer target from engine. ## Choose an integration - Godot 4 Web: copy the GDScript adapter; use browser WebRTC. No JavaScript import is required. https://github.com/egemeric/edgeplay/tree/main/integrations/godot - Godot 4 native: same adapter plus a compatible official webrtc-native GDExtension. - Web JS/TS, Canvas, Phaser, Three.js, PixiJS: import EdgePlayClient from https://edgeplay.edgesocket.net/sdk/index.js and use quickStart(). - Unity/Unreal/custom native: implement the documented protocol with a compatible WebRTC library. No dedicated Unity or Unreal SDK is shipped. Verify target support. - Other Web exports: bridge the browser SDK into the engine's scripting interface. Do not assume native socket/WebRTC packages work in WebGL/browser builds. - Existing native UDP/ENet games (e.g. SuperTuxKart): use the experimental local edgeplay-bridge companion, preserving existing networking and player-hosted simulation. No Go rewrite of the game or central game server. https://github.com/egemeric/edgeplay/tree/main/integrations/supertuxkart This is not a browser port or embedded C++ SDK. An optional STK 1.5 webcam patch/preview launcher lives in integrations/supertuxkart/webcam; avatar wire messages remain game-specific. Do not send ENet through sendInput/sendEvent. Read the full engine contract before implementation: https://github.com/egemeric/edgeplay/tree/main/docs/engines.md Wire contract: https://github.com/egemeric/edgeplay/tree/main/docs/protocol.md Godot source: https://raw.githubusercontent.com/egemeric/edgeplay/main/integrations/godot/addons/edgeplay/edgeplay.gd Browser SDK types: https://raw.githubusercontent.com/egemeric/edgeplay/main/sdk/index.d.ts Working web example: https://github.com/egemeric/edgeplay/tree/main/web/quickstart ## Non-negotiable architecture Use mode "hosted-p2p". Room creator is "host" (master peer). Only that player's copy of the game simulates and validates all players. Guests send current controls, receive snapshots and interpolate their rendering. EdgePlay runs rooms/signaling; EdgeSocket supplies NAT traversal and TURN. Neither hosts or executes game code. There is no authoritative server mode, Go game upload or server-game scaffold. Room discovery/signaling is centralized; game simulation is peer-owned. Do not claim the entire service is decentralized or that TURN never carries game packets. ## Implement the user's game 1. Preserve solo gameplay. Separate readControls, fixed-step simulation, snapshot and render hooks without replacing the engine or existing game rules. 2. Add Play online, Join, Copy invite and Leave with clear connection status. Display invite link for web games or roomId.inviteToken for native games. Keep hostToken, sessionToken, admin keys and EdgeSocket identity tokens private. 3. Browser: new EdgePlayClient(), then await client.quickStart({name, game, mode:"hosted-p2p"}). It returns {session,isHost,inviteUrl,room}. Register session.on handlers BEFORE await session.connect(). Godot: instantiate EdgePlay, register signals BEFORE await quick_start(name,game,invitation); wait for connected. 4. Run 20–30 Hz network ticks. Every player sends current controls; master applies local input only once, validates guest input and broadcasts compact snapshots. Guests do not run a competing authoritative simulation. Adapt schemas to this actual game, not the example's dx/dy fields. Reliable events carry one-off actions. 5. Remove departed entities and stale controls; send initial state to late joiners. Show errors and retain offline play if room creation or network setup fails. No silent new room on invalid invites. No automatic master migration: master departure closes the room. Godot adapter currently requires explicit rejoin after disconnect; browser SDK supports signaling resume within the grace window. 6. Verify two players, movement from both sides, late join, leave/rejoin, master departure, invalid/full/expired room, reconnect and offline fallback. Test actual export target (Godot Web and native separately), direct and TURN paths when available. Report exact tested versions and any untested platform/route. ## Limits and protocol Public POST /v1/demo/rooms needs no admin key. 6 creates/minute/IP, 2–16 players, 1 hour room lifetime, 2 minutes empty, 30 minute player sessions (capped by room expiry). Send fewer than 120 input/event frames/s per peer. Inputs/events <=16 KiB, state <=64 KiB; use realtime for <=1150 byte state and reliable for larger state. Drop stale input sequences and state ticks. Master validates sender, sizes, rates and game rules; signaling cannot validate peer-to-peer gameplay. Host trust is inherent: this is not cheat-proof competitive server authority. Godot WebRTC API has no portable relay-only policy guarantee: the included adapter rejects relay-only rooms. Normal TURN fallback is supported through supplied ICE servers. Native builds require the extension; do not label them tested without it. ## Optional MCP Run node /absolute/path/to/edgeplay/mcp/index.js. No admin key needed for players. Use edgeplay_scaffold_client (engine and target), edgeplay_integration_guide and edgeplay_create_room. Operator APIs are not part of the player setup. Go remains an internal diagnostics client/bot; users never need Go to integrate their game.