Skip to main content

ServerPacketReceiver

A class in Root.Township, Alta.Networking.

The server's packet receiver. Each frame it takes packets from the transport, handles unreliable ones per connection, then handles buffered reliable ones, and records timing stats. Server only.

Constructors​

MemberWhat it is
ServerPacketReceiver(ISocket socket)Creates a ServerPacketReceiver from socket.

Fields​

MemberWhat it is
const int MaximumMessageSizeLargest message size in bytes (1500).
static AverageNumber ProcessingReliableMsAverage time spent handling reliable packets per frame.
static AverageNumber ProcessingUnreliableMsAverage time spent handling unreliable packets per frame.
static AverageNumber ReceivingMsAverage time spent reading from the transport per frame.
static AverageNumber ReliableMessagesPerFrameAverage reliable packets handled per frame.
static AverageNumber UnreliableMessagesPerFrameAverage unreliable packets handled per frame.
10 private and internal fields
MemberWhat it is
private ConnectionChannel[] channelsThe channels from NetworkingSettings, used to tell reliable from unreliable.
private byte errorUnused.
private static Logger loggerNLog logger for this class.
private Stopwatch processingReliableTimerStopwatch for reliable handling.
private Stopwatch processingUnreliableTimerStopwatch for unreliable handling.
private Dictionary<int, ServerMessageReceiverPerConnection> receiversPer-connection receivers by connection id.
private Stopwatch receivingTimerStopwatch for reading from the transport.
private List<ServerPacketReceiver.ReceivedMessageFromConnection> reliableBuffersReliable packets received this frame, reused between frames.
private int reliableReceivedCountHow many entries of reliableBuffers are in use this frame.
private HashSet<int> unregisteredConnectionIdentifiersUnknown connection ids already logged, so each is only logged once.

Properties​

MemberWhat it is
protected ISocket Socket { get; set; }The socket this receiver works for.

Methods​

MemberWhat it is
void ReceivePackets()Runs one frame of receiving and handling, then records the stats.
3 private and internal methods
MemberWhat it is
private void CreateConnection(ITransportConnection connection)On a new transport connection, makes or reuses its per-connection receiver and passes the event on.
private void DestroyConnection(ITransportConnection connection)On transport disconnect, tells the per-connection receiver and removes it.
private void Alta.NetworkingTransport.IPacketProcessor.Process(ITransportSocket socket, int connectionId, ArraySegment<byte> data, int channel)Copies a received packet; reliable ones are buffered for this frame, unreliable ones go to the connection's receiver.