HeadlinesBriefing favicon HeadlinesBriefing.com

BlindSpot's C++/Unity Game Architecture

DEV Community •
×

BlindSpot is a 3:3 top-down multiplayer shooter being built with a decoupled architecture. The server uses C++ with Boost.Asio for asynchronous I/O, while the client is a Unity (C#) application. They communicate using a custom binary protocol built on Google Protocol Buffers to ensure type safety and efficiency.

The network layer handles packet serialization and reassembly on both ends. The server serializes messages, adds a header with packet ID and length, and sends data via async_write. The client buffers incoming stream data, reconstructs packets by reading the header, and processes them. This pattern manages TCP's stream nature without blocking.

For scalability and safety, the server uses smart pointers (shared_ptr) and the enable_shared_from_this pattern to manage object lifecycles within async handlers. A Packet Handler pattern routes logic based on packet IDs, simplifying feature additions. The server operates on an io_context event loop, designed to handle thousands of connections with a small thread pool.