protected override void OnOpen(TimeSpan timeout)
        {
            if (!is_service_side)
            {
                NetworkStream ns = client.GetStream();
                frame = new TcpBinaryFrameManager(TcpBinaryFrameManager.DuplexMode, ns, is_service_side)
                {
                    Encoder = this.Encoder,
                    Via     = this.Via
                };
                frame.ProcessPreambleInitiator();
                frame.ProcessPreambleAckInitiator();
                session = new TcpDuplexSession(this);                  // make sure to shutdown the session once it has initiated one.
            }
            else
            {
                // server side
                Stream s = client.GetStream();

                frame = new TcpBinaryFrameManager(TcpBinaryFrameManager.DuplexMode, s, is_service_side)
                {
                    Encoder = this.Encoder
                };

                // FIXME: use retrieved record properties in the request processing.

                frame.ProcessPreambleRecipient();
                frame.ProcessPreambleAckRecipient();
            }
        }
        public override bool TryReceive(TimeSpan timeout, out Message message)
        {
            ThrowIfDisposedOrNotOpen();

            // FIXME: there seems to be some pipeline or channel-
            // recycling issues, which could be mostly workarounded
            // by delaying input receiver.
            // This place is not ideal, but it covers both loops in
            // ChannelDispatcher and DuplexClientRuntimeChannel.
            Thread.Sleep(50);

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

            message = frame.ReadSizedMessage();
            // FIXME: this may not be precise, but connection might be reused for some weird socket state transition (that's what happens). So as a workaround, avoid closing the session by sending EndRecord from this channel at OnClose().
            if (message == null)
            {
                session = null;
                return(false);
            }

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

            return(true);
        }
 void DiscardSession()
 {
     if (client.Connected)
     {
         frame.WriteEndRecord();
     }
     session = null;
 }
Пример #4
0
 void DiscardSession()
 {
     frame.WriteEndRecord();
     session = null;
 }
Пример #5
0
		protected override void OnOpen (TimeSpan timeout)
		{
			if (! is_service_side) {
				NetworkStream ns = client.GetStream ();
				frame = new TcpBinaryFrameManager (TcpBinaryFrameManager.DuplexMode, ns, is_service_side) {
					Encoder = this.Encoder,
					Via = this.Via };
				frame.ProcessPreambleInitiator ();
				frame.ProcessPreambleAckInitiator ();
				session = new TcpDuplexSession (this); // make sure to shutdown the session once it has initiated one.
			} else {
				// server side
				Stream s = client.GetStream ();

				frame = new TcpBinaryFrameManager (TcpBinaryFrameManager.DuplexMode, s, is_service_side) { Encoder = this.Encoder };

				// FIXME: use retrieved record properties in the request processing.

				frame.ProcessPreambleRecipient ();
				frame.ProcessPreambleAckRecipient ();
			}
		}
Пример #6
0
		public override bool TryReceive (TimeSpan timeout, out Message message)
		{
			ThrowIfDisposedOrNotOpen ();

			// FIXME: there seems to be some pipeline or channel-
			// recycling issues, which could be mostly workarounded 
			// by delaying input receiver.
			// This place is not ideal, but it covers both loops in
			// ChannelDispatcher and DuplexClientRuntimeChannel.
			Thread.Sleep (50);

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

			message = frame.ReadSizedMessage ();
			// FIXME: this may not be precise, but connection might be reused for some weird socket state transition (that's what happens). So as a workaround, avoid closing the session by sending EndRecord from this channel at OnClose().
			if (message == null) {
				session = null;
				return false;
			}

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

			return true;
		}
Пример #7
0
		void DiscardSession ()
		{
			if (client.Connected)
				frame.WriteEndRecord ();
			session = null;
		}