示例#1
0
        /// <summary>
        /// Start packet entity
        /// </summary>
        private void SendEntity()
        {
            SendPacket packet = mPacket;

            if (packet != null)
            {
                int count = packet.Read(Buffer, 0, mSender.GetBufferSize());

                mCursor += count;

                // Send
                SendAsync(0, count);


                SendDelivery delivery = mDelivery;
                if (delivery != null)
                {
                    // Progress
                    float progress = (float)mCursor / mTotal;
                    // Post Callback
                    if (IsNotifyProgress(progress))
                    {
                        delivery.PostSendProgress(packet, mProgress);
                    }
                }
            }
        }
示例#2
0
        public AsyncSendDispatcher(Sender sender, SendDelivery delivery, float progressPrecision)
            : base(progressPrecision)
        {
            mQueue    = new ConcurrentQueue <SendPacket>();
            mSender   = sender;
            mDelivery = delivery;

            // Set Buffer
            SetBuffer(new byte[sender.GetBufferSize()], 0, sender.GetBufferSize());
        }
示例#3
0
        /// <summary>
        /// Notify send progress
        /// </summary>
        private void NotifyProgress()
        {
            SendPacket   packet   = mPacket;
            SendDelivery delivery = mDelivery;

            if (packet != null && delivery != null)
            {
                // Progress
                float progress = (float)mCursor / mTotal;
                // Post Callback
                if (IsNotifyProgress(progress))
                {
                    delivery.PostSendProgress(packet, mProgress);
                }
            }
        }
示例#4
0
        public new void Dispose()
        {
            if (!IsDisposed())
            {
                SendPacket packet = mPacket;
                mPacket = null;

                SendDelivery delivery = mDelivery;
                mDelivery = null;

                Sender sender = mSender;
                mSender = null;

                if (packet != null && delivery != null)
                {
                    if (mCursor < mTotal)
                    {
                        packet.EndPacket();
                        packet.SetSuccess(false);
                        delivery.PostSendProgress(packet, 1);
                    }
                }

                if (sender != null)
                {
                    sender.Dispose();
                }
                try
                {
                    SetBuffer(null, 0, 0);
                }
                catch (Exception) { }

                // Clear
                while (mQueue.TryDequeue(out packet))
                {
                }

                base.Dispose();
            }
        }
示例#5
0
        public BlinkConn(Sender sender,
                         Receiver receiver,
                         SendDelivery sendDelivery,
                         ReceiveDelivery receiveDelivery,
                         BlinkDelivery blinkDelivery,
                         Resource resource,
                         BlinkParser parser,
                         float progressPrecision)
        {
            mSender   = sender;
            mReceiver = receiver;
            mResource = resource;

            mSendDelivery    = sendDelivery;
            mReceiveDelivery = receiveDelivery;
            mBlinkDelivery   = blinkDelivery;

            mParser = parser;

            // Init this
            Init(progressPrecision);
        }
示例#6
0
        public BlinkConn(Sender sender,
            Receiver receiver,
            SendDelivery sendDelivery,
            ReceiveDelivery receiveDelivery,
            BlinkDelivery blinkDelivery,
            Resource resource,
            BlinkParser parser,
            float progressPrecision)
        {
            mSender = sender;
            mReceiver = receiver;
            mResource = resource;

            mSendDelivery = sendDelivery;
            mReceiveDelivery = receiveDelivery;
            mBlinkDelivery = blinkDelivery;

            mParser = parser;

            // Init this
            Init(progressPrecision);
        }