private void InitializePools() { if (m_configuration.UseMessageRecycling) { m_storagePool = new List <byte[]>(16); m_outgoingMessagesPool = new NetQueue <NetOutgoingMessage>(4); m_incomingMessagesPool = new NetQueue <NetIncomingMessage>(4); } else { m_storagePool = null; m_outgoingMessagesPool = null; m_incomingMessagesPool = null; } }
internal NetConnection(NetPeer peer, IPEndPoint remoteEndPoint) { m_peer = peer; m_peerConfiguration = m_peer.Configuration; m_status = NetConnectionStatus.None; m_visibleStatus = NetConnectionStatus.None; m_remoteEndPoint = remoteEndPoint; m_sendChannels = new NetSenderChannelBase[NetConstants.NumTotalChannels]; m_receiveChannels = new NetReceiverChannelBase[NetConstants.NumTotalChannels]; m_queuedOutgoingAcks = new NetQueue <NetTuple <NetMessageType, int> >(4); m_queuedIncomingAcks = new NetQueue <NetTuple <NetMessageType, int> >(4); m_statistics = new NetConnectionStatistics(this); m_averageRoundtripTime = -1.0f; m_currentMTU = m_peerConfiguration.MaximumTransmissionUnit; }
internal NetUnreliableSenderChannel(NetConnection connection, int windowSize, NetDeliveryMethod method) { m_connection = connection; m_windowSize = windowSize; m_windowStart = 0; m_sendStart = 0; m_receivedAcks = new NetBitVector(NetConstants.NumSequenceNumbers); m_queuedSends = new NetQueue <NetOutgoingMessage>(8); m_doFlowControl = true; if (method == NetDeliveryMethod.Unreliable && connection.Peer.Configuration.SuppressUnreliableUnorderedAcks == true) { m_doFlowControl = false; } }
/// <summary> /// NetPeer constructor /// </summary> public NetPeer(NetPeerConfiguration config, NetGameConfiguration netGameConfiguration) { m_configuration = config; NetGameConfiguration = netGameConfiguration; m_statistics = new NetPeerStatistics(this); m_releasedIncomingMessages = new NetQueue <NetIncomingMessage>(4); m_unsentUnconnectedMessages = new NetQueue <NetTuple <IPEndPoint, NetOutgoingMessage> >(2); m_connections = new List <NetConnection>(); m_connectionLookup = new Dictionary <IPEndPoint, NetConnection>(); m_handshakes = new Dictionary <IPEndPoint, NetConnection>(); IPAddress iPAddress = netGameConfiguration.NetIPAddress; m_senderRemote = (EndPoint) new IPEndPoint(iPAddress, 0); m_status = NetPeerStatus.NotRunning; m_receivedFragmentGroups = new Dictionary <NetConnection, Dictionary <int, ReceivedFragmentGroup> >(); }
private void InitializePools() { m_storageSlotsUsedCount = 0; if (m_configuration.UseMessageRecycling) { m_storagePool = new List <byte[]>(16); m_outgoingMessagesPool = new NetQueue <NetOutgoingMessage>(4); m_incomingMessagesPool = new NetQueue <NetIncomingMessage>(4); } else { m_storagePool = null; m_outgoingMessagesPool = null; m_incomingMessagesPool = null; } m_maxCacheCount = m_configuration.RecycledCacheMaxCount; }
internal NetConnection(NetPeer peer, NetEndPoint remoteEndPoint) { m_peer = peer; m_peerConfiguration = m_peer.Configuration; m_status = NetConnectionStatus.None; m_outputtedStatus = NetConnectionStatus.None; m_visibleStatus = NetConnectionStatus.None; m_remoteEndPoint = remoteEndPoint; m_sendChannels = new NetSenderChannelBase[NetConstants.NumTotalChannels]; m_receiveChannels = new NetReceiverChannelBase[NetConstants.NumTotalChannels]; m_queuedOutgoingAcks = new NetQueue <NetTuple <NetMessageType, int> >(4); m_queuedIncomingAcks = new NetQueue <NetTuple <NetMessageType, int> >(4); m_statistics = new NetConnectionStatistics(this); m_averageRoundtripTime = -1.0f; m_currentMTU = m_peerConfiguration.MaximumTransmissionUnit; //Set the remote identifier m_remoteUniqueIdentifier = Interlocked.Increment(ref remoteUniqueIdCount); }
internal NetConnection(NetBase owner, IPEndPoint remoteEndPoint, byte[] localHailData, byte[] remoteHailData) { m_owner = owner; m_remoteEndPoint = remoteEndPoint; m_localHailData = localHailData; m_remoteHailData = remoteHailData; m_futureClose = double.MaxValue; m_throttleDebt = owner.m_config.m_throttleBytesPerSecond; // slower start m_statistics = new NetConnectionStatistics(this, 1.0f); m_unsentMessages = new NetQueue <OutgoingNetMessage>(6); m_lockedUnsentMessages = new NetQueue <OutgoingNetMessage>(3); m_status = NetConnectionStatus.Connecting; // to prevent immediate removal on heartbeat thread InitializeReliability(); InitializeFragmentation(); InitializeStringTable(); //InitializeCongestionControl(32); }
/// <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> >(); }
protected NetBase(NetConfiguration config) { Debug.Assert(config != null, "Config must not be null"); if (string.IsNullOrEmpty(config.ApplicationIdentifier)) { throw new ArgumentException("Must set ApplicationIdentifier in NetConfiguration!"); } m_config = config; m_receiveBuffer = new NetBuffer(config.ReceiveBufferSize); m_sendBuffer = new NetBuffer(config.SendBufferSize); //by WuNan @2016/09/28 14:26:34 #if (UNITY_IOS || UNITY_TVOS) && !UNITY_EDITOR if (uLink.NetworkUtility.IsSupportIPv6()) { m_senderRemote = (EndPoint) new NetworkEndPoint(IPAddress.IPv6Any, 0); } else { m_senderRemote = (EndPoint) new NetworkEndPoint(IPAddress.Any, 0); } #else m_senderRemote = (EndPoint) new NetworkEndPoint(IPAddress.Any, 0); #endif m_statistics = new NetBaseStatistics(); m_receivedMessages = new NetQueue <IncomingNetMessage>(4); m_tempBuffer = new NetBuffer(256); m_discovery = new NetDiscovery(this); m_heartbeatCounter = new NetFrequencyCounter(3.0f); m_localRndSignature = new byte[NetConstants.SignatureByteSize]; NetRandom.Instance.NextBytes(m_localRndSignature); m_unsentOutOfBandMessages = new NetQueue <NetBuffer>(); m_unsentOutOfBandRecipients = new NetQueue <NetworkEndPoint>(); m_susmQueue = new Queue <SUSystemMessage>(); // default enabled message types m_enabledMessageTypes = NetMessageType.Data | NetMessageType.StatusChanged; }