{
PeerTransportBindingElement source;
BindingContext context;
- Uri listen_uri;
TChannel channel;
- MessageEncoder encoder;
AutoResetEvent accept_handle = new AutoResetEvent (false);
public PeerChannelListener (PeerTransportBindingElement source,
BindingContext context)
- : base (context.Binding)
+ : base (context)
{
this.source = source;
- // FIXME: consider ListenUriMode
- // FIXME: there should be some way to post-provide Uri in case of null listenerUri in context.
- listen_uri = context.ListenUriBaseAddress != null ?
- new Uri (context.ListenUriBaseAddress, context.ListenUriRelativeAddress) : null;
- foreach (BindingElement be in context.RemainingBindingElements) {
+ foreach (BindingElement be in context.Binding.Elements) {
MessageEncodingBindingElement mbe = be as MessageEncodingBindingElement;
if (mbe != null) {
- encoder = CreateEncoder<TChannel> (mbe);
+ MessageEncoder = CreateEncoder<TChannel> (mbe);
break;
}
}
- if (encoder == null)
- encoder = new BinaryMessageEncoder ();
+ if (MessageEncoder == null)
+ MessageEncoder = new BinaryMessageEncoder ();
}
public PeerResolver Resolver { get; set; }
get { return source; }
}
- public MessageEncoder MessageEncoder {
- get { return encoder; }
- }
-
- public override Uri Uri {
- get { return listen_uri; }
- }
-
protected override TChannel OnAcceptChannel (TimeSpan timeout)
{
- DateTime start = DateTime.Now;
+ DateTime start = DateTime.UtcNow;
if (channel != null)
if (!accept_handle.WaitOne (timeout))
throw new TimeoutException ();
- channel = PopulateChannel (timeout - (DateTime.Now - start));
+ channel = PopulateChannel (timeout - (DateTime.UtcNow - start));
((CommunicationObject) (object) channel).Closed += delegate {
this.channel = null;
accept_handle.Set ();