BlitsMe.TransportEmulator.ProxyTransportManager.SendToDestination C# (CSharp) Méthode

SendToDestination() private méthode

private SendToDestination ( IPacket packet ) : void
packet IPacket
Résultat void
        private void SendToDestination(IPacket packet)
        {
            int periodLeft = PeriodLength - (Environment.TickCount - _periodStart);
            if (periodLeft <= 0)
            {
                Logger.Info("Resetting period, no more time left in period");
                ResetPeriod();
                periodLeft = PeriodLength;
            }
            if (_bytesThisPeriod > _transportForm.Bandwidth * 1024)
            {
                // wait out the period
                Logger.Info("Blocking, already sent " + _bytesThisPeriod + " this period, will wait " + periodLeft + "ms");
                Thread.Sleep(periodLeft);
                ResetPeriod();
                periodLeft = PeriodLength;
            }
            _bytesThisPeriod += packet.GetBytes().Length;

            // dump it onto the physical layer of the other proxy
            proxy.PhysicalLayer.Enqueue(new PhysicalPacketHolder(packet));
            Logger.Info("Sent packet through physical layer, " + _bytesThisPeriod + " so far this period, " + periodLeft + "ms left.");
            lock (proxy.PhysicalLayerLock)
                Monitor.Pulse(proxy.PhysicalLayerLock);
        }