void ProcessRequest(ISmtpMessage smtpMessage, Smtp.Fields headers, Header[] msgHeaders, String contentType, String seqNum, MemoryStream stm, ref bool fIsOneWay) { IMessage outMsg = null; fIsOneWay = false; // Deserialize - Stream to IMessage IMessage inMsg = CoreChannel.DeserializeMessage(contentType, stm, true, null, msgHeaders); InternalRemotingServices.RemotingTrace("Deserialized message"); if (inMsg == null) { throw new Exception(CoreChannel.GetResourceString("Remoting_DeserializeMessage")); } // Set URI - BUGBUG: temp hack String url = ((IMethodMessage)inMsg).Uri; String objectURL = null; try { Parse(url, out objectURL); } catch (Exception) { objectURL = url; } inMsg.Properties["__Uri"] = objectURL; // Dispatch Call InternalRemotingServices.RemotingTrace("ChannelServices.SyncDispatchMessage - before"); outMsg = ChannelServices.SyncDispatchMessage(inMsg); InternalRemotingServices.RemotingTrace("ChannelServices.SyncDispatchMessage - after"); // We do not send a reply for one way messages. If the message // is not one way and we have a null return message then we // throw an exception if (null == outMsg) { MethodBase method = ((IMethodMessage)inMsg).MethodBase; fIsOneWay = RemotingServices.IsOneWay(method); if (!fIsOneWay) { throw new Exception(CoreChannel.GetResourceString("Remoting_DispatchMessage")); } } else { ReplyMessage(outMsg, smtpMessage, seqNum, headers); InternalRemotingServices.RemotingTrace("Reply sent"); } }
void ProcessResponse(ISmtpMessage smtpMessage, String contentType, String seqNum, MemoryStream stm) { InternalRemotingServices.RemotingTrace("Received response"); // Notify the waiting object that its response // has arrived WaitObject obj = (WaitObject)m_hashTable[seqNum]; if (null != obj) { InternalRemotingServices.RemotingTrace("Found an object waiting"); // First remove the object in a threadsafe manner // so that we do not deliver the response twice // due to duplicate replies or other errors from // Smtp lock (obj) { if (m_hashTable.Contains(seqNum)) { InternalRemotingServices.RemotingTrace("Found an object to notify"); m_hashTable.Remove(seqNum); IMethodCallMessage request = (IMethodCallMessage)obj.Request; Header[] h = new Header[3]; h[0] = new Header("__TypeName", request.TypeName); h[1] = new Header("__MethodName", request.MethodName); h[2] = new Header("__MethodSignature", request.MethodSignature); IMessage response = CoreChannel.DeserializeMessage(contentType, stm, false, request, h); InternalRemotingServices.RemotingTrace("Deserialized message"); if (response == null) { throw new Exception(CoreChannel.GetResourceString("Remoting_DeserializeMessage")); } // Notify the object obj.Notify(response); } } } else { InternalRemotingServices.RemotingTrace("No object waiting"); } }