Ejemplo n.º 1
0
 protected void OnSendError(SendingQueue queue, CloseReason closeReason)
 {
     queue.Clear();
     m_SendingQueuePool.Push(queue);
     RemoveStateFlag(SocketState.InSending);
     ValidateClosed(closeReason);
 }
Ejemplo n.º 2
0
 protected void OnSendError(SendingQueue queue, CloseReason closeReason)
 {
     queue.Clear();
     m_SendingQueuePool.Return(queue);
     OnSendEnd();
     ValidateClosed(closeReason);
 }
Ejemplo n.º 3
0
        protected virtual void OnSendingCompleted(SendingQueue queue)
        {
            queue.Clear();
            m_SendingQueuePool.Push(queue);

            var newQueue = m_SendingQueue;

            if (IsInClosingOrClosed)
            {
                //has data is being sent and the socket isn't closed
                if (newQueue.Count > 0 && !TryValidateClosedBySocket(out Socket client))
                {
                    StartSend(newQueue, newQueue.TrackID, false);
                    return;
                }

                OnSendEnd();
                return;
            }

            if (newQueue.Count == 0)
            {
                OnSendEnd();

                if (newQueue.Count > 0)
                {
                    StartSend(newQueue, newQueue.TrackID, true);
                }
            }
            else
            {
                StartSend(newQueue, newQueue.TrackID, false);
            }
        }
Ejemplo n.º 4
0
        protected virtual void OnSendingCompleted(SendingQueue queue)
        {
            queue.Clear();
            m_SendingQueuePool.Push(queue);

            if (IsInClosingOrClosed)
            {
                RemoveStateFlag(SocketState.InSending);
                return;
            }

            var newQueue = m_SendingQueue;

            if (newQueue.Count == 0)
            {
                RemoveStateFlag(SocketState.InSending);

                if (newQueue.Count > 0)
                {
                    StartSend(newQueue, newQueue.TrackID, true);
                }
            }
            else
            {
                StartSend(newQueue, newQueue.TrackID, false);
            }
        }
Ejemplo n.º 5
0
        private void SAE_SendCompleted(object sender, SocketAsyncEventArgs e)
        {
            SendingQueue sendQueue = e.UserToken as SendingQueue;

            if (sendQueue == SendingQueue.Null)
            {
                Trace.Error("未知错误help!~");
            }
            else if (e.SocketError != SocketError.Success)
            {
                this.RaiseSended(sendQueue, false);
                this.SendEnd(sendQueue, CloseReason.Exception, new Exception("send complete error"));
            }
            else if (sendQueue.Count <= e.BytesTransferred)
            {
                e.SetBuffer(null, 0, 0);
                e.BufferList = null;
                this.RaiseSended(sendQueue, true);
                sendQueue.Clear();
                this.Monitor.SendingPool.Release(sendQueue);
                this.state.RemoveState(SessionState.SENDING);
                this.PreSend();
            }
            else
            {
                sendQueue.TrimByte(e.BytesTransferred);
                this.InternalSend(sendQueue);
            }
        }
Ejemplo n.º 6
0
 private void SendEnd(SendingQueue queue, CloseReason reason, Exception exception)
 {
     if (queue != null)
     {
         queue.Clear();
         this.Monitor.SendingPool.Release(queue);
     }
     this.state.RemoveState(SessionState.SENDING);
     this.Close(reason);
 }
Ejemplo n.º 7
0
        protected virtual void OnSendingCompleted(SendingQueue queue)
        {
            queue.Clear();
            m_SendingQueuePool.Return(queue);

            var newQueue = m_SendingQueue;

            if (IsInClosingOrClosed)
            {
                Socket client;

                //has data is being sent and the socket isn't closed
                if (newQueue.Count > 0 && !TryValidateClosedBySocket(out client))
                {
                    StartSend(newQueue, newQueue.TrackID, false);
                    return;
                }

                OnSendEnd(true);
                return;
            }

            if (newQueue.Count == 0)
            {
                OnSendEnd();

                if (newQueue.Count > 0)
                {
                    StartSend(newQueue, newQueue.TrackID, true);
                }
            }
            else
            {
                StartSend(newQueue, newQueue.TrackID, false);
            }
        }
Ejemplo n.º 8
0
 protected void OnSendError(SendingQueue queue, CloseReason closeReason)
 {
     queue.Clear();
     m_SendingQueuePool.Return(queue);
     OnSendEnd();
     ValidateClosed(closeReason);
 }
Ejemplo n.º 9
0
 protected void OnSendError(SendingQueue queue, CloseReason closeReason)
 {
     queue.Clear();
     m_SendingQueuePool.Push(queue);
     OnSendEnd(closeReason, true);
 }
Ejemplo n.º 10
0
        protected virtual void OnSendingCompleted(SendingQueue queue)
        {
            queue.Clear();
            m_SendingQueuePool.Push(queue);

            if (IsInClosingOrClosed)
            {
                RemoveStateFlag(SocketState.InSending);
                return;
            }

            var newQueue = m_SendingQueue;

            if (newQueue.Count == 0)
            {
                RemoveStateFlag(SocketState.InSending);

                if (newQueue.Count > 0)
                {
                    StartSend(newQueue, newQueue.TrackID, true);
                }
            }
            else
            {
                StartSend(newQueue, newQueue.TrackID, false);
            }
        }
Ejemplo n.º 11
0
 protected void OnSendError(SendingQueue queue, CloseReason closeReason)
 {
     queue.Clear();
     m_SendingQueuePool.Push(queue);
     RemoveStateFlag(SocketState.InSending);
     ValidateClosed(closeReason);
 }
Ejemplo n.º 12
0
        protected virtual void OnSendingCompleted(SendingQueue queue)
        {
            queue.Clear();
            m_SendingQueuePool.Push(queue);

            var newQueue = m_SendingQueue;

            if (newQueue.Count == 0)
            {
                m_InSending = 0;

                if (newQueue.Count > 0)
                {
                    StartSend(newQueue, newQueue.TrackID, true);
                }
            }
            else
            {
                StartSend(newQueue, newQueue.TrackID, false);
            }
        }
Ejemplo n.º 13
0
        protected virtual void OnSendingCompleted(SendingQueue queue)
        {
            queue.Clear();
            m_SendingQueuePool.Push(queue);

            var newQueue = m_SendingQueue;

            if (IsInClosingOrClosed)
            {
                //has data is being sent and the socket isn't closed
                if (newQueue.Count > 0 && m_Client != null)
                {
                    StartSend(newQueue, newQueue.TrackID, false);
                    return;
                }

                OnSendEnd(true);
                return;
            }

            if (newQueue.Count == 0)
            {
                OnSendEnd();

                if (newQueue.Count > 0)
                {
                    StartSend(newQueue, newQueue.TrackID, true);
                }
            }
            else
            {
                StartSend(newQueue, newQueue.TrackID, false);
            }
        }