← All Workshops

MudEngine Part 11: Peer-to-Peer with iroh

Step 14 / 14
◀ Prev

Congratulations

You tore down the central server and rebuilt the MudEngine as a peer-to-peer application — the host's own machine is the world, the mesh carries the state, and every player is just another endpoint on the topic.

The architecture in three sentences

One desktop process owns the authoritative GameEngine and broadcasts its answers through iroh-gossip; the same engine answers the host's own actions and every player's requests alike. Desktop players speak QUIC directly; browser players reach the topic through a WebSocket relay — the relay is stateless plumbing, not a second server. The GameEngine never touches a socket: it receives a ClientMessage and returns Vec<ServerMessage>, and the network layer takes care of the rest.

What you removed compared to Part 10

  • dioxus/fullstack + dioxus-fullstack — no Axum, no use_websocket, no SSR
  • server = ["dioxus/server"] — the feature and the entire src/game/server/ module
  • dx serve for the desktop app — cargo run is all you need now
  • The server's set_server_url("http://localhost:8080") and cfg(feature = "server") in main.rs — the mesh does not live at an HTTP endpoint

The series is done

You built a multiplayer MUD engine through eleven parts:

  1. Requirements
  2. Single-player REPL
  3. File-based world
  4. Single-player Dioxus GUI
  5. Component library
  6. Multiplayer with WebSockets
  7. Save & load
  8. Inventory & chat
  9. Cooperative quest
  10. Desktop with Blitz renderer
  11. Peer-to-peer with iroh

The dungeon is yours — extend the world, add quests, build an editor, or port it to mobile. The engine is in your hands.

🎯 What we achieved
ConceptWhat it did
iroh EndpointEach player is a QUIC endpoint identified by an Ed25519 node id
iroh-gossipPlumtree pub-sub mesh — replaces broadcast::Sender across the LAN
Topic id (blake3)Both peers derive the same topic from the name — no config sync
mDNS address lookupSame-network peers find each other's real IP without a relay
Router + ALPNRegisters gossip on the endpoint's accept loop — must stay alive
Authoritative hostOne engine owns state; peers render; no CRDT needed
WebSocket relayStateless bytes-in/bytes-out bridge — step 2 for browsers
GameEngine extractionTransport-agnostic logic: &mut self → Vec<ServerMessage>
Ephemeral client keyNo persistent host file needed; dials out
Host.secret persistenceStable host node id across launches — players always rejoin
📚 References
Step 14 / 14
◀ Prev