private bool hostStarted; // Indicates whether call to ChannelHost.Start() is current //--------------------------------------------------------------------- // Implementation /// <summary> /// Constructor. /// </summary> /// <param name="context">The <see cref="BindingContext" /> holding the information necessary to construct the channel stack.</param> /// <exception cref="InvalidOperationException">Thrown if problems were found with the binding parameters.</exception> internal LillTekChannelListener(BindingContext context) { this.maxAcceptedChannels = ServiceModelHelper.MaxAcceptedChannels; // $todo(jeff.lill): Hardcoded bkTaskInterval = ServiceModelHelper.DefaultBkTaskInterval; // This too this.context = context; this.uri = GetListenUri(context); this.ep = ServiceModelHelper.ToMsgEP(uri); this.onBkTask = new AsyncCallback(OnBkTask); this.sessionMode = false; this.hostStarted = false; // Initialize the message encoder factory from the binding context if // one was specified. Use the binary message encoding factory otherwise. if (context.BindingParameters.FindAll <MessageEncodingBindingElement>().Count > 1) { throw new InvalidOperationException("Multiple MessageEncodingBindingElements were found in the BindingParameters of the BindingContext."); } MessageEncodingBindingElement element = context.BindingParameters.Find <MessageEncodingBindingElement>(); if (element != null) { messageEncoderFactory = element.CreateMessageEncoderFactory(); } else { messageEncoderFactory = new BinaryMessageEncodingBindingElement().CreateMessageEncoderFactory(); } }
private PayloadSizeEstimator payloadEstimator; // Used to estimate the buffer required to serialize // the next message sent /// <summary> /// Constructor. /// </summary> /// <param name="channelManager">The responsible channel manager.</param> /// <param name="remoteAddress">The remote <see cref="EndpointAddress" />.</param> /// <param name="via">The first transport hop <see cref="Uri" />.</param> /// <param name="encoder">The <see cref="MessageEncoder" /> for serializing messages to the wire format.</param> public OutputChannel(ChannelManagerBase channelManager, EndpointAddress remoteAddress, Uri via, MessageEncoder encoder) : base(channelManager) { ServiceModelHelper.ValidateEP(remoteAddress.Uri); ServiceModelHelper.ValidateEP(via); this.remoteAddress = remoteAddress; this.via = via; this.encoder = encoder; this.ep = ServiceModelHelper.ToMsgEP(remoteAddress.Uri); this.payloadEstimator = new PayloadSizeEstimator(ServiceModelHelper.PayloadEstimatorSampleCount); }
private DuplexSession session; // Underlying LillTek Messaging session /// <summary> /// Constructor. /// </summary> /// <param name="channelManager">The responsible channel manager.</param> /// <param name="remoteAddress">The remote <see cref="EndpointAddress" />.</param> /// <param name="via">The first transport hop <see cref="Uri" />.</param> /// <param name="encoder">The <see cref="MessageEncoder" /> for serializing messages to the wire format.</param> public OutputSessionChannel(ChannelManagerBase channelManager, EndpointAddress remoteAddress, Uri via, MessageEncoder encoder) : base(channelManager) { ServiceModelHelper.ValidateEP(remoteAddress.Uri); ServiceModelHelper.ValidateEP(via); this.ep = ServiceModelHelper.ToMsgEP(remoteAddress.Uri); if (ep.Broadcast) { throw new ArgumentException("Sessionful channels cannot accept broadcast endpoints.", "remoteAddress"); } this.remoteAddress = remoteAddress; this.via = via; this.encoder = encoder; this.payloadEstimator = new PayloadSizeEstimator(ServiceModelHelper.PayloadEstimatorSampleCount); this.session = ChannelHost.Router.CreateDuplexSession(); }
public void ServiceModelHelper_ToMsgEP() { MsgEP ep; try { ep = ServiceModelHelper.ToMsgEP("lilltek.physical://root/0/1"); Assert.Fail("Expected ArgumentException"); // physical addressing is not supported } catch (ArgumentException) { } ep = ServiceModelHelper.ToMsgEP("lilltek.logical://myservice/1"); Assert.AreEqual("logical://myservice/1", ep.ToString()); ep = ServiceModelHelper.ToMsgEP("lilltek.abstract://myservice/2"); Assert.AreEqual("logical://myservice/2", ep.ToString()); // "abstract" gets converted to "logical" ep = ServiceModelHelper.ToMsgEP(new Uri("lilltek.logical://myservice/1")); Assert.AreEqual("logical://myservice/1", ep.ToString()); ep = ServiceModelHelper.ToMsgEP(new Uri("lilltek.abstract://myservice/2")); Assert.AreEqual("logical://myservice/2", ep.ToString()); // "abstract" gets converted to "logical" try { ep = ServiceModelHelper.ToMsgEP((string)null); Assert.Fail("Expected an ArgumentNullException"); } catch (ArgumentNullException) { } try { ep = ServiceModelHelper.ToMsgEP((Uri)null); Assert.Fail("Expected an ArgumentNullException"); } catch (ArgumentNullException) { } try { ep = ServiceModelHelper.ToMsgEP("http://www.foo.com"); Assert.Fail("Expected an ArgumentException"); } catch (ArgumentException) { } try { ep = ServiceModelHelper.ToMsgEP(new Uri("http://www.foo.com")); Assert.Fail("Expected an ArgumentException"); } catch (ArgumentException) { } }