Пример #1
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();
            }

            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));

            frame.ReadEndRecord();              // both
            return(ret);
        }
Пример #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));
            }

            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);

            // 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));
        }
Пример #3
0
        public override RequestContext ReceiveRequest(TimeSpan timeout)
        {
            DateTime start = DateTime.Now;

            if (client == null)
            {
                return(null);
            }

            if (timeout <= TimeSpan.Zero)
            {
                throw new ArgumentException(String.Format("Timeout value must be positive value. It was {0}", timeout));
            }

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

            var msg = frame.ReadUnsizedMessage(timeout);

            // 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));
        }
Пример #4
0
        public override RequestContext ReceiveRequest(TimeSpan timeout)
        {
            // It is used while it is already closed.
            if (client == null || !client.Connected)
            {
                return(null);
            }

            if (timeout <= TimeSpan.Zero)
            {
                throw new ArgumentException(String.Format("Timeout value must be positive value. It was {0}", timeout));
            }
            var msg = frame.ReadUnsizedMessage(timeout);

            frame.ReadEndRecord();
            return(new TcpRequestContext(this, msg));
        }
Пример #5
0
        public override Message Request(Message input, TimeSpan timeout)
        {
            DateTime start = DateTime.Now;

            CreateClient(timeout);

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

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

            frame.WriteEndRecord();

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

            frame.ReadEndRecord();
            return(ret);
        }
Пример #6
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, EncodingRecord = TcpBinaryFrameManager.EncodingBinary };

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

			var msg = frame.ReadUnsizedMessage (timeout);
			// 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);
		}