Multiplayer Doom on Cloudflare Workers
May 18, 2021Celso Martinho

Summary
This post details the technical challenges and solutions involved in porting multiplayer Doom to run on Cloudflare Workers and Durable Objects. It covers compiling Chocolate Doom to WebAssembly using Emscripten, adapting the game's main loop for an event-driven browser environment, and implementing a new network module (`net_websockets.c`) to tunnel UDP-based game traffic over WebSockets. Key technical contributions include creating a fake IP address for routing, implementing a packet queue to buffer TCP-based WebSocket traffic, and demonstrating the feasibility of low-latency, real-time multiplayer gaming on the edge.