Beispiel #1
0
        bool IsReceiver(ISmtpMessage smtpMessage, ref ISmtpOnArrival receiver)
        {
            bool fReceive = false;

            // Get the one and only receiver
            //BCLDebug.Assert(m_receiverGuid != Guid.Empty, "m_receiverGuid != Guid.Empty");
            receiver = (ISmtpOnArrival)s_receiverTable[m_mailboxName];
            if (null == receiver)
            {
                throw new Exception(CoreChannel.GetResourceString("Remoting_NoReceiverRegistered"));
            }

            if (receiver == this)
            {
                String mailbox = smtpMessage.To;

                // Only process those messages which are addressed to us
                InternalRemotingServices.RemotingTrace("mailbox " + m_mailboxName + " receiver " + mailbox);
                if ((null != m_mailboxName) &&
                    (-1 != CultureInfo.CurrentCulture.CompareInfo.IndexOf(mailbox, m_mailboxName, CompareOptions.IgnoreCase)))
                {
                    InternalRemotingServices.RemotingTrace("Mailboxes match");
                    fReceive = true;
                }
                else
                {
                    // We don't do anything with messages not addressed to us
                    receiver = null;
                }
            }

            return(fReceive);
        }
Beispiel #2
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;
            }
        }