Skip to main content

ServerSync

A class in Root.Township, Alta.Networking.

The server side ISync that SyncFactory.Create makes on the server. Keeps the server read and write handlers and can limit incoming messages to one owner player.

Constructors​

MemberWhat it is
ServerSync(INetworkEntity entity, EntityMessageType type)Creates a ServerSync from entity and type.

Fields​

2 private and internal fields
MemberWhat it is
private bool isRelaySet by OnServerReadAndRelay; not read anywhere.
private IPlayer ownerThe only player allowed to send this sync, or null for anyone.

Methods​

MemberWhat it is
ISync OnClientRead(SerializeMethod reader)Does nothing on the server.
ISync OnClientWrite(SerializeMethod writer)Does nothing on the server.
ISync OnServerRead(SerializeMethod reader)Sets the method that reads messages from clients.
ISync OnServerReadAndRelay(SerializeMethod reader, SerializeMethod writer)Sets both the reader and the writer, for data the server reads and passes on.
ISync OnServerWrite(SerializeMethod writer)Sets the method that writes data sent to clients.
void SendToPlayer(IPlayer player)Sends this sync's data to one player.
ISync SetOwner(IPlayer player)Sets the only player whose messages are accepted.
protected override void MessageHandler(IPlayer player, Stream stream)Runs the reader only for messages from a valid sender.
1 private and internal method
MemberWhat it is
private bool IsValidMessageOrigin(IPlayer player)True if no owner is set or the sender is the owner; otherwise logs an error.