Exemplo n.º 1
0
		public override RequestContext ReceiveRequest (TimeSpan timeout)
		{
			if (timeout <= TimeSpan.Zero)
				throw new ArgumentException (String.Format ("Timeout value must be positive value. It was {0}", timeout));

			DateTime start = DateTime.Now;

			// FIXME: use timeout
			if (client == null)
				client = ((TcpChannelListener<IReplyChannel>) Manager).AcceptTcpClient (timeout);
			NetworkStream ns = client.GetStream ();
			frame = new TcpBinaryFrameManager (TcpBinaryFrameManager.SingletonUnsizedMode, ns, true) { Encoder = this.Encoder };

			// FIXME: use timeout
			if (!frame.ProcessPreambleRecipient ())
				return null;
			frame.ProcessPreambleAckRecipient ();

			var msg = frame.ReadUnsizedMessage (timeout);

			Logger.LogMessage (MessageLogSourceKind.TransportReceive, ref msg, info.BindingElement.MaxReceivedMessageSize);

			// LAMESPEC: it contradicts the protocol explanation at section 3.1.1.1.1 in [MC-NMF].
			// Moving ReadEndRecord() after context's WriteUnsizedMessage() causes TCP connection blocking.
			frame.ReadEndRecord ();
			return new TcpRequestContext (this, msg);
		}
Exemplo n.º 2
0
        public override RequestContext ReceiveRequest(TimeSpan timeout)
        {
            if (timeout <= TimeSpan.Zero)
            {
                throw new ArgumentException(String.Format("Timeout value must be positive value. It was {0}", timeout));
            }

            // FIXME: use timeout
            if (client == null)
            {
                client = ((TcpChannelListener <IReplyChannel>)Manager).AcceptTcpClient(timeout);
            }
            NetworkStream ns = client.GetStream();

            frame = new TcpBinaryFrameManager(TcpBinaryFrameManager.SingletonUnsizedMode, ns, true)
            {
                Encoder = this.Encoder
            };

            // FIXME: use timeout
            if (!frame.ProcessPreambleRecipient())
            {
                return(null);
            }
            frame.ProcessPreambleAckRecipient();

            var msg = frame.ReadUnsizedMessage(timeout);

            Logger.LogMessage(MessageLogSourceKind.TransportReceive, ref msg, info.BindingElement.MaxReceivedMessageSize);

            // LAMESPEC: it contradicts the protocol explanation at section 3.1.1.1.1 in [MC-NMF].
            // Moving ReadEndRecord() after context's WriteUnsizedMessage() causes TCP connection blocking.
            frame.ReadEndRecord();
            return(new TcpRequestContext(this, msg));
        }
Exemplo n.º 3
0
        public override Message Request(Message input, TimeSpan timeout)
        {
            DateTime start = DateTime.Now;

            // FIXME: use timeouts.
            frame.ProcessPreambleInitiator();
            frame.ProcessPreambleAckInitiator();

            if (input.Headers.To == null)
            {
                input.Headers.To = RemoteAddress.Uri;
            }
            if (input.Headers.MessageId == null)
            {
                input.Headers.MessageId = new UniqueId();
            }

            Logger.LogMessage(MessageLogSourceKind.TransportSend, ref input, int.MaxValue);              // It is not a receive buffer

            frame.WriteUnsizedMessage(input, timeout - (DateTime.Now - start));

            // LAMESPEC: it contradicts the protocol described at section 3.1.1.1.1 in [MC-NMF].
            // Moving this WriteEndRecord() after ReadUnsizedMessage() causes TCP connection blocking.
            frame.WriteEndRecord();

            var ret = frame.ReadUnsizedMessage(timeout - (DateTime.Now - start));

            Logger.LogMessage(MessageLogSourceKind.TransportReceive, ref ret, info.BindingElement.MaxReceivedMessageSize);

            frame.ReadEndRecord();              // both
            return(ret);
        }