Unreal Engine 4 Genvid Client/Server¶
Adapt your code¶
To follow the Genvid MILE SDK architecture you need to use two classes based on:
These two classes will help you integrate the Client/Server architecture.
How it works¶
The client-owned PlayerController sends a Remote Procedure Call (RPC) to the server with authority (through the GenvidEvents and GenvidCommands Components).
The server receives the RPC and triggers the corresponding custom event. Then it sends an RPC to all connected clients from the GameState class (Multicast).
To allow an owner without authority (client) to send an RPC to the server,
PlayerController-based class provided by Unreal Engine 4.
This is the only place where an RPC can be made from the client to the server.
You need to add your Genvid Streams/Events/Commands to your PlayerController-class, as described in the Instantiation section.
Don’t forget to check the
Replicated checkbox to enable the Client/Server flow.
See Genvid Event Parameters.
To allow an owner with authority (server) to send an RPC to all connected
clients, use the
GameState-based class provided by Unreal Engine 4.
This is one place where an RPC can be made from the server to a client.
To make send an RPC from the server:
Set the replicate mode to Multicast and Reliable.
With these settings, the server will send an RPC to all connected clients.
At this stage, you’re always in the GameState but on the client side. You can now call your code.
To complete the loop, call the GameState custom-event from the GenvidEvents or GenvidCommands components attached to the PlayerController.