Ejemplo n.º 1
0
        // END: DICTIONARY IMPLEMENTION

        // ISmtpOnArrival
        // Receives incoming messages which can either be a request to dispatch
        // a call or a response to a call
        /// <include file='doc\SmtpChannel.uex' path='docs/doc[@for="SmtpChannel.OnArrival"]/*' />
        public virtual void OnArrival(ISmtpMessage smtpMessage, ref CdoEventStatus EventStatus)
        {
            bool fIsOneWay = false;

            try
            {
                InternalRemotingServices.RemotingTrace("Reached OnArrival");

                ISmtpOnArrival receiver = null;
                // Get the global receiver. If this instance is the global
                // receiver then proceed else delegate to it.
                if (IsReceiver(smtpMessage, ref receiver))
                {
                    // Check whether this message is a SOAP request message or a
                    // SOAP response message
                    String subject  = smtpMessage.Subject;
                    bool   fRequest = false;
                    // Proceed only if this is a SOAP request or response
                    if (s_defaultSenderSubject.Equals(subject))
                    {
                        fRequest = true;
                    }
                    else if (!s_defaultReceiverSubject.Equals(subject))
                    {
                        throw new Exception("Invalid subject type " + subject);
                    }

                    // Extract the releavant mail headers
                    String      contentType = null;
                    Smtp.Fields headers     = null;
                    Header[]    msgHeaders  = null;
                    String      seqNum      = GetHeaders(smtpMessage, ref headers, ref contentType, ref msgHeaders);

                    // Create a stream out of the body of the mail
                    MemoryStream stm = new MemoryStream(Encoding.ASCII.GetBytes(smtpMessage.TextBody));
                    InternalRemotingServices.RemotingTrace("Created memory stream");

                    // Check whether this is a request or a response message
                    if (fRequest)
                    {
                        // Dispatch this method and determine whether this
                        // method is one way.
                        ProcessRequest(smtpMessage, headers, msgHeaders, contentType, seqNum, stm, ref fIsOneWay);
                    }
                    else
                    {
                        ProcessResponse(smtpMessage, contentType, seqNum, stm);
                    }
                }
                else
                {
                    if (null != receiver)
                    {
                        // A message was addressed to us .. delegate to the
                        // global receiver
                        receiver.OnArrival(smtpMessage, ref EventStatus);
                    }
                }

                InternalRemotingServices.RemotingTrace("Success!");
            }
            catch (Exception e)
            {
                InternalRemotingServices.RemotingTrace("Reached an exception " + e.StackTrace);
                InternalRemotingServices.RemotingTrace("Exception message " + e.Message);
                if (!fIsOneWay)
                {
                    //@TODO
                    //ProcessException(smtpMessage, contentType, headers, seqNum);
                }
            }
            finally
            {
                EventStatus = CdoEventStatus.cdoRunNextSink;
            }
        }
Ejemplo n.º 2
0
		public void OnArrival(CDO.Message Msg, ref CdoEventStatus EventStatus)
		{
			MessageBox.Show(Msg.Subject, "Message arrived!", MessageBoxButtons.OK, MessageBoxIcon.Information);
			EventStatus = CdoEventStatus.cdoRunNextSink;
		}