Using the High-Level Networking API

Quickly create distributed, stateful gameplay with ARDK’s built-in high level networking API.


Imagine the simplest way to replicate an object’s position with the MultipeerNetworking interface. It probably involves serializing the position Vector3 into a byte[], sending that byte[] with a specific tag, then listening for that tag and deserializing the Vector3 on the receiving end. Extending this pattern to support two objects would require another tag (or some prefix on the byte[] to specify the target). What about extending this to thousands of objects with different lifetimes, or adding additional fields (each object now has a color, and a name), or ownership over an object (which peer can manipulate it, who sees updates)?

The High Level Networking API (Hlapi) is a networking layer that sits on top of the MultipeerNetworking interface and solves these problems with a hierarchical addressing scheme. Each networked object is represented as NetworkGroup interface with a NetworkId tag, and each NetworkGroup contains any number of NetworkedDataHandlers, which are identified by strings and are the actual handlers of the data (e.g., sends the current position of the GameObject that it is attached to, and uses any received data to update position). Intermediate classes (such as the HlapiSession and NetworkGroup) deal with networking problems such as addressing, caching, and serializing data.


With this architecture in mind, the Hlapi includes several features to quickly start building a multiplayer experience.

  • Network Spawning/Despawning : Register your object as a NetworkedUnityObject, the networked equivalent of a GameObject, and spawn (or despawn) that object for all peers in the session with a single API call.

  • Authority: Define ownership over networked data, so all peers agree on who is permitted to despawn objects, write to certain fields, listen for updates on those fields and more.

  • Networked Transforms: Drag-and-drop the NetTransform onto a GameObject to automatically hook into the Hlapi and enable the peer with Authority over the object to manipulate its transform for all other peers in the network session.

  • Generic Networked Fields: Construct a NetworkedField<T> to automatically propagate updates of a generic value to other peers in the network session.

  • Message Streams: Send and receive objects of type T in a stream instead of raw byte messages using the MessageStreamReplicator<T>.

See Also