Beispiel #1
0
            /// <summary>
            /// Is called when SMTP server 354 response sending has completed.
            /// </summary>
            /// <param name="op">Asynchronous operation.</param>
            private void Send354ResponseCompleted(SMTP_Session.SendResponseAsyncOP op)
            {
                try{
                    // RFC 5321.4.4 trace info.
                    byte[] recevived = m_pSession.CreateReceivedHeader();
                    m_pSession.m_pMessageStream.Write(recevived,0,recevived.Length);
                    
                    // Create asynchronous read period-terminated opeartion.
                    SmartStream.ReadPeriodTerminatedAsyncOP readPeriodTermOP = new SmartStream.ReadPeriodTerminatedAsyncOP(
                        m_pSession.m_pMessageStream,
                        m_pSession.Server.MaxMessageSize,
                        SizeExceededAction.JunkAndThrowException
                    );
                    // This event is raised only if read period-terminated opeartion completes asynchronously.
                    readPeriodTermOP.Completed += new EventHandler<EventArgs<SmartStream.ReadPeriodTerminatedAsyncOP>>(delegate(object sender,EventArgs<SmartStream.ReadPeriodTerminatedAsyncOP> e){                
                        MessageReadingCompleted(readPeriodTermOP);
                    });
                    // Read period-terminated completed synchronously.
                    if(m_pSession.TcpStream.ReadPeriodTerminated(readPeriodTermOP,true)){
                        MessageReadingCompleted(readPeriodTermOP);
                    }
                }
                catch(Exception x){
                    m_pException = x;
                    m_pSession.LogAddException("Exception: " + m_pException.Message,m_pException);
                    SetState(AsyncOP_State.Completed);
                }

                op.Dispose();
            }
Beispiel #2
0
            /// <summary>
            /// Is called when SMTP server "final" response sending has completed.
            /// </summary>
            private void SendFinalResponseCompleted(SMTP_Session.SendResponseAsyncOP op)
            {                 
                if(op.Error != null){
                    m_pException = op.Error;
                }

                SetState(AsyncOP_State.Completed);
                
                op.Dispose();
            }