Skip to main content

SceneSerializer

A class in Root.Township, Alta.Networking.Internal.

Sends and reads the regular state updates of every EntitySerializer in a network scene, packing as many as fit into each SceneSerialize message. The server writes per connection.

Constructors​

MemberWhat it is
SceneSerializer(INetworkSceneInternal networkScene, EntityManager entityManager)Creates a SceneSerializer from networkScene and entityManager.

Fields​

MemberWhat it is
static AverageNumber MessagesPerConnectionRunning average of messages sent per connection per pass.
static AverageNumber SerializationTimeMsRunning average time spent preparing entity data.
static AverageNumber SerializeToConnectionsMsRunning average time to write and send to all connections.
static SerializingEntityHandler WritingEntityStatic debug hook called for every entity written.
6 private and internal fields
MemberWhat it is
private List<Connection> connectionsReused list of the connections to send to this pass.
private EntityManager entityManagerWhere the serialized entities come from.
private static Logger loggerLogger for this class.
private INetworkSceneInternal networkSceneThe scene being serialized.
private int serializeFrameIndexCounter that staggers which entities get an on frame.
private static Stopwatch timerStopwatch for the serialization timing stats.

Properties​

MemberWhat it is
ConnectionChannel SerializationChannel { get; set; }Channel the serialize messages go out on.

Methods​

MemberWhat it is
void InitialSyncEntities(Player target)Server: sends a joining player a sync message for every embedded scene entity, then destroy messages for missing ones.
void PrepareSerializeEntities(bool isServer)Has each serializer capture its data for this pass, using the server or client set.
void SendSerialized(ISocket socket)Writes and sends entity data to every connection on the socket, split over messages (logs an error at 1000).
void SerializeRead(Connection connection, StreamReader stream)Reads a serialize message and hands each entity's bits to its serializer. Skips unknown entities and data the sender may not write.
void SerializeWrite(StreamWriter stream, Connection connection, ref int startIndex)Writes serializers into one message up to MaxBitsPerSerializationMessage. Sets startIndex to where the next message resumes, or -1 when done.
1 private and internal method
MemberWhat it is
private void UpdateEntityData(IEnumerable<EntitySerializer> serializers)Runs each entity serializer's SerializeData, with three passes in four counted as off frames so idle entities update less often.

Used in​

Members of other types that take, return or hold a SceneSerializer: