4. High Level API (HLAPI)
◎Built on top of of Transport Real Time
Layer
◎Work in conjunction with Internet Services
◎Provides services for multiplayer such as:
Message handlers
High performance serialization
Distributed object management
State synchronization
Network classes: Server, Client, Connection, etc
6. High Level API Components
NetworkReader
◎ NetworkReader is a class for reading objects from byte streams.
NetworkServer
◎ NetworkServer is a High-Level-API class that manages connections from
multiple clients.
NetworkClient
◎ NetworkClient is a class that manages a network connection to a server
◎ It is used to send messages and receive messages from the server.
◎ The NetworkClient also helps manage spawned network objects, and
routing of RPC message and network events.
7. High Level API Components
Network Identity
This component controls an object’s network identity, and it makes the
networking system aware of it.
8. High Level API Components
The NetworkManager is a class
that allows control the state of a
networked game.
9. High Level API Components
The NetworkLobbyManager is a
specialized type of
NetworkManager that provides a
multiplayer lobby before entering
the main play scene of the game.
11. High Level API Components
[ServerCallback]
Do server-side stuff, initializing game objects can be used
here. Syncing objects can also be used here.
newObject.transform.position = newObjectPosition;
Network Transform will sync new position across all
clients. Values are updated on the server side, clients will
have their old positions marked as Dirty() and update to
the server's values.
12. High Level API Components
[ClientCallback]
Do client-side stuff, make them only run on clients, but
not generate warnings. Client may have registered prefab
from the Network Manager, but it's better to have it
available in the Hierarchy before continuing.
GameObject prefabObject =
GameObject.FindGameObjectWithTag("SamplePrefab");
if (prefabObject != null) {
CmdDoAction(prefabObject);
}
13. High Level API Components
[Command]
You do stuffs that the client wants the server to do or just
have the server do something for the client.
GameObject obj = Instantiate(objectToUse);
NetworkServer.SpawnWithClientAuthority(obj, this.connectionToClient);
Once the server has done whatever it needs to do, you
can choose if you want to have all clients do other
actions.
RpcDoAction();
14. High Level API Components
[ClientRpc]
Do broadcasting, where all clients will do.
if (!this.hasAuthority) {
//Clients with no authority can do.
Ping(new Vector3(0f, 10f, 0f), Color.red);
} else {
//Do something in which the client itself has
Ping(new Vector3(0f, 10f, 0f), Color.green);
}
16. High Level API Components
Pros
◎ Free to use, if using Unity service, free package covers max 20 users.
◎ If using own server, unlimited usage
◎ Deep customizable API, both on lower and higher levels
◎ Matchmaking, ‘nuff said
◎ Having both client and server codes in the same project
◎ Much quicker to program than usual server
Cons
◎ If there is one, I don’t see it yet