← All Workshops

MudEngine Part 11: Peer-to-Peer (Hybrid)

Congratulations!

You just rebuilt the MudEngine as a peer-to-peer application — no central server, no fullstack deployment, no cloud dependency.

The architecture in three sentences

Desktop players connect directly via QUIC — no server, no relay. Browser players connect via WebSocket to a tiny relay that pipes their messages into the same gossip mesh. The host's desktop app owns the game world — the same GameState, can_move(), and quest logic from Parts 7–9, running in-process alongside the Dioxus UI.

What you removed compared to Part 10

  • dioxus/fullstack — no Axum, no server functions, no SSR
  • dioxus-fullstack — no use_websocket, no WebSocketOptions
  • #[cfg(feature = "server")] — no server/server split
  • dx serve — the desktop binary runs with cargo run
  • UUID dependency — iroh's PublicKey replaces UUID for player identity

What's next?

This workshop series is complete. You have built a multiplayer MUD engine through eleven parts:

  1. Environment setup
  2. Terminal REPL
  3. File-based world loading
  4. Dioxus GUI (single-player)
  5. Component library polish
  6. Multiplayer with WebSockets
  7. Save & load persistence
  8. Inventory and chat
  9. Cooperative quest
  10. Desktop with Blitz renderer
  11. Peer-to-peer hybrid (this part)

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

🎯 What we achieved
ConceptHow we used it
iroh EndpointEach player is a QUIC endpoint with a unique Ed25519 key
iroh-gossipReplaced broadcast::Sender for real-time game state distribution
mDNS discoveryPlayers on the same LAN find each other automatically
Authoritative hostOne desktop player owns GameState; everyone else connects to them
WebSocket relayBridges browser players into the gossip mesh without modifying game logic
Game engine extractionGameEngine is a plain Rust struct, independent of any transport
📚 What we learned
ConceptHow we used it
iroh EndpointQUIC-based P2P connection with Ed25519 identity
iroh-gossipPublish-subscribe mesh for broadcasting game state
mDNS address lookupAutomatic LAN peer discovery
Authoritative hostOne peer owns the game state; no CRDT needed
WebSocket relayBridges browser clients into the iroh mesh
GameEngine extractionGame logic as a library, independent of transport
Hybrid architectureDesktop players use QUIC, browser players use WebSocket