Example #1
0
        private void SendQueuedPackets()
        {
            _reliableOrderedChannel.SendNextPackets();
            _reliableUnorderedChannel.SendNextPackets();
            _sequencedChannel.SendNextPackets();
            _simpleChannel.SendNextPackets();

            //If merging enabled
            if (_mergePos > 0)
            {
                if (_mergeCount > 1)
                {
                    NetUtils.DebugWrite("Send merged: " + _mergePos + ", count: " + _mergeCount);
                    _peerListener.SendRaw(_mergeData.RawData, 0, NetConstants.HeaderSize + _mergePos, _remoteEndPoint);
#if STATS_ENABLED
                    Statistics.PacketsSent++;
                    Statistics.BytesSent += (ulong)(NetConstants.HeaderSize + _mergePos);
#endif
                }
                else
                {
                    //Send without length information and merging
                    _peerListener.SendRaw(_mergeData.RawData, NetConstants.HeaderSize + 2, _mergePos - 2, _remoteEndPoint);
#if STATS_ENABLED
                    Statistics.PacketsSent++;
                    Statistics.BytesSent += (ulong)(_mergePos - 2);
#endif
                }
                _mergePos   = 0;
                _mergeCount = 0;
            }
        }
Example #2
0
 /// <summary>
 /// Flush all queued packets
 /// </summary>
 public void Flush()
 {
     if (_connectionState != ConnectionState.Connected)
     {
         return;
     }
     //lock (_flushLock)
     {
         _reliableOrderedChannel.SendNextPackets();
         _reliableUnorderedChannel.SendNextPackets();
         _reliableSequencedChannel.SendNextPackets();
         _sequencedChannel.SendNextPackets();
         _unreliableChannel.SendNextPackets();
         SendMerged();
     }
 }
Example #3
0
        /// <summary>
        /// Flush all queued packets
        /// </summary>
        public void Flush()
        {
            if (_connectionState != ConnectionState.Connected)
            {
                return;
            }
            lock (_flushLock)
            {
                _reliableOrderedChannel.SendNextPackets();
                _reliableUnorderedChannel.SendNextPackets();
                _reliableSequencedChannel.SendNextPackets();
                _sequencedChannel.SendNextPackets();
                _unreliableChannel.SendNextPackets();

                //If merging enabled
                if (_mergePos > 0)
                {
                    if (_mergeCount > 1)
                    {
                        NetUtils.DebugWrite("[P]Send merged: " + _mergePos + ", count: " + _mergeCount);
                        _netManager.SendRaw(_mergeData.RawData, 0, NetConstants.HeaderSize + _mergePos, _remoteEndPoint);
#if STATS_ENABLED
                        Statistics.PacketsSent++;
                        Statistics.BytesSent += (ulong)(NetConstants.HeaderSize + _mergePos);
#endif
                    }
                    else
                    {
                        //Send without length information and merging
                        _netManager.SendRaw(_mergeData.RawData, NetConstants.HeaderSize + 2, _mergePos - 2, _remoteEndPoint);
#if STATS_ENABLED
                        Statistics.PacketsSent++;
                        Statistics.BytesSent += (ulong)(_mergePos - 2);
#endif
                    }
                    _mergePos   = 0;
                    _mergeCount = 0;
                }
            }
        }