The Worker SDK in C++ is an implementation of the Worker SDK, based on the C API, and is designed to highlight SpatialOS’s capabilities. It comes with code generation, and makes use of C++ templates and the standard template library (STL) as a common, type-safe, and easy to understand set of generic algorithms and data structures on which you can build worker logic.
It is aimed at evaluation, quick prototyping, and potentially workers that you create without using a game engine. The implementation is deliberately not targeted at a frictionless, performance-critical integration with an existing or planned game engine or abstraction layer (for that use case, refer to the Worker SDK in C). This is due to the following drawbacks:
- It can be difficult, even wasteful, to interoperate with if the rest of your codebase does not use STL.
- Your codebase might make different design choices, for example:
- If you want to use your own code generation, you have to write this on top of the output of the code generation we provide.
- It is generic and not optimized for high performance.
- understanding SpatialOS’s concepts and abstractions.
- evaluating SpatialOS’s capabilities.
- quick prototyping of workers that you create without using a game engine.
May also be suitable for:
- production use of workers that you create without using a game engine.
Not recommended for:
- integration into a game engine for production use.
The SDK provides functionality to write a worker that:
- connects to a SpatialOS simulated world
(see Connect to SpatialOS)
- can subscribe to information for a part of the world
(see Handle data received from SpatialOS)
- can send and receive component updates
(see Send data to SpatialOS)
The most important units of functionality in the C++ worker API are:
worker::Locatorwhich is responsible for querying for and connecting to remote cloud deployments.
worker::Connection, which represents a worker's connection to a SpatialOS simulated world.
worker::Dispatcher, which is responsible for
invoking user-provided callbacks based on data received from SpatialOS via the
worker::Entity, which is a container for the component data associated with a single entity.
worker::View, which is an optional drop-in replacement for the
worker::Dispatcherthat additionally maintains a map from entity ID to
For more, see
<improbable/worker.h>, the C++ API reference documentation,
or the pages under "Using the Worker SDK in C++" in this section.
You can use the C++ blank project as a starting point for a project using the Worker SDK in C++, or to add a C++ worker to an existing SpatialOS project.
The APIs are lower-level than the a game engine integration like the Unity3D integration
If you're using a game engine we don't have an integration with, you can use this SDK to integrate that game engine with SpatialOS. See Integrate a game engine for details.
2019-12-13 Page updated with editorial review: added introductory section
Updated 3 months ago