- Home /
Authoritative Server Architecture
Hello!
I'm currently working on a project that requires an authoritative server structure. Unfortunately, I'm very new to multiplayer programming, and so I've been having trouble understanding some of the structural requirements of the entire thing.
My question is about networked calls: Should ALL networking calls be called from their owners?
I created a demo scene to experiment. In my scene I have 3 classes:
Agent: A little colored cube with a Rigidbody. Can be moved through networked calls via Move(float x, float y, float z)
Player: Controller class. References an Agent in the scene, and sends input via Move(float x, float y, float z)
AuthServer: Owns every Agent, and
tells each Player which Agent to
reference.
This is what my Player loop looks like:
Agent _agent;
void Update()
{
if (!View.IsMine || _agent == null) return;
var __input = GetInput();
// The fist argument of the method is which View the Sync is being called from
NetSolution.SyncMethod(_agent, "Move", SendTo.Server, __input.x, __input.y, __input.z);
}
In that example, I'm trying to send a networked message ("Move") straight from the Agent's View, even though I don't own it, and I've been told this is a security infringement. I guess the alternative would be to do something like:
void Update()
{
if (!View.IsMine || _agent == null) return;
var __input = GetInput();
NetSolution.SyncMethod(this, "RequestMove", SendTo.Server, __input.x, __input.y, __input.z);
}
public void RequestMove(float x, float y, float z)
{
if (!NetSolution.IsHost) return;
_agent.Move(x,y,z);
}
In my opinion, adding the extra method is just an extra step, when I could be syncing the method straight to its receiver. Am I missing something? Is that a security infringement? Should the networking solution support that?