/// <summary> /// Initializes a new instance of the <see cref="NetPeerStatisticsSnapshot"/> class. /// </summary> /// <param name="stats">The <see cref="NetPeerStatistics"/> to copy the values from.</param> public NetPeerStatisticsSnapshot(NetPeerStatistics stats) { _recvBytes = stats.ReceivedBytes; _recvPackets = stats.ReceivedPackets; _recvMsg = stats.ReceivedMessages; _sentBytes = stats.SentBytes; _sentPackets = stats.SentPackets; _sentMsg = stats.SentMessages; }
/// <summary> /// NetPeer constructor /// </summary> public NetPeer(NetPeerConfiguration config) { m_configuration = config; m_statistics = new NetPeerStatistics(this); m_releasedIncomingMessages = new NetQueue <NetIncomingMessage>(4); m_unsentUnconnectedMessages = new NetQueue <NetTuple <NetEndPoint, NetOutgoingMessage> >(2); m_connections = new List <NetConnection>(); m_connectionLookup = new Dictionary <NetEndPoint, NetConnection>(); m_senderRemote = (EndPoint) new NetEndPoint(IPAddress.Any, 0); m_status = NetPeerStatus.NotRunning; m_receivedFragmentGroups = new Dictionary <NetConnection, Dictionary <int, ReceivedFragmentGroup> >(); }
/// <summary> /// NetPeer constructor /// </summary> public NetPeer(NetPeerConfiguration config) { m_configuration = config; m_statistics = new NetPeerStatistics(this); m_releasedIncomingMessages = new NetQueue<NetIncomingMessage>(4); m_unsentUnconnectedMessages = new NetQueue<NetTuple<NetEndPoint, NetOutgoingMessage>>(2); m_connections = new List<NetConnection>(); m_connectionLookup = new Dictionary<NetEndPoint, NetConnection>(); m_handshakes = new Dictionary<NetEndPoint, NetConnection>(); m_senderRemote = (EndPoint)new NetEndPoint(IPAddress.Any, 0); m_status = NetPeerStatus.NotRunning; m_receivedFragmentGroups = new Dictionary<NetConnection, Dictionary<int, ReceivedFragmentGroup>>(); }
/// <summary> /// Constructs the peer with a given configuration. /// </summary> public NetPeer(NetPeerConfiguration config) { Configuration = config ?? throw new ArgumentNullException(nameof(config)); if (Configuration.LocalAddress.AddressFamily == AddressFamily.InterNetworkV6) { _senderRemote = new IPEndPoint(IPAddress.IPv6Any, 0); } else { _senderRemote = new IPEndPoint(IPAddress.Any, 0); } Statistics = new NetPeerStatistics(this); UPnP = new NetUPnP(this); Status = NetPeerStatus.NotRunning; }
/// <summary> /// NetPeer constructor /// </summary> public NetPeer(NetPeerConfiguration config) { m_configuration = config; m_statistics = new NetPeerStatistics(this); m_releasedIncomingMessages = new NetQueue <NetIncomingMessage>(4); m_unsentUnconnectedMessages = new NetQueue <NetTuple <NetEndPoint, NetOutgoingMessage> >(2); m_connections = new List <NetConnection>(); m_connectionLookup = new Dictionary <NetEndPoint, NetConnection>(); m_handshakes = new Dictionary <NetEndPoint, NetConnection>(); if (m_configuration.LocalAddress.AddressFamily == AddressFamily.InterNetworkV6) { m_senderRemote = (EndPoint) new IPEndPoint(IPAddress.IPv6Any, 0); } else { m_senderRemote = (EndPoint) new IPEndPoint(IPAddress.Any, 0); } m_status = NetPeerStatus.NotRunning; m_receivedFragmentGroups = new Dictionary <NetConnection, Dictionary <int, ReceivedFragmentGroup> >(); }
/// <summary> /// Gets a <see cref="NetPeerStatisticsSnapshot"/> containing the changes in values in the <see cref="NetPeerStatistics"/> /// since the given <see cref="NetPeerStatisticsSnapshot"/> was made. /// </summary> /// <param name="a">The current <see cref="NetConnectionStatistics"/> containing the up-to-date values.</param> /// <param name="b">The <see cref="NetPeerStatisticsSnapshot"/> containing the base values.</param> /// <returns>A <see cref="NetPeerStatisticsSnapshot"/> containing the changes in values in the <see cref="NetPeerStatistics"/> /// since the given <see cref="NetPeerStatisticsSnapshot"/> was made.</returns> public static NetPeerStatisticsSnapshot Diff(NetPeerStatistics a, NetPeerStatisticsSnapshot b) { var ret = new NetPeerStatisticsSnapshot(a.ReceivedBytes - b.ReceivedBytes, a.ReceivedPackets - b.ReceivedPackets, a.ReceivedMessages - b.ReceivedMessages, a.SentBytes - b.SentBytes, a.SentPackets - b.SentPackets, a.SentMessages - b.SentMessages); return ret; }
public static ConnectionStatistics Convert(NetPeerStatistics n,float rtt) { if (n != null) { ConnectionStatistics c = new ConnectionStatistics( n.ReceivedPackets, n.ReceivedBytes, n.SentPackets, n.SentBytes, n.ReceivedBytes, n.SentBytes); c.RoundTripTime = rtt; return c; } else { ConnectionStatistics c = new ConnectionStatistics(); c.RoundTripTime = rtt; return c; } }