+2009-06-11 Atsushi Enomoto <atsushi@ximian.com>
+
+ * HttpChannelListener.cs, TcpChannelListener.cs,
+ ChannelListenerBase_1.cs : put common internal listener base
+ and let it handle those async stuff.
+
2009-06-10 Atsushi Enomoto <atsushi@ximian.com>
* ReplyChannelBase.cs : fix wrong null delegate check point.
namespace System.ServiceModel.Channels
{
+ internal abstract class InternalChannelListenerBase<TChannel>
+ : ChannelListenerBase<TChannel>
+ where TChannel : class, IChannel
+ {
+ protected InternalChannelListenerBase ()
+ : base ()
+ {
+ }
+
+ protected InternalChannelListenerBase (IDefaultCommunicationTimeouts timeouts)
+ : base (timeouts)
+ {
+ }
+
+ Func<TimeSpan,TChannel> accept_channel_delegate;
+ Func<TimeSpan,bool> wait_delegate;
+ Action<TimeSpan> open_delegate, close_delegate;
+
+ protected override IAsyncResult OnBeginAcceptChannel (
+ TimeSpan timeout, AsyncCallback callback,
+ object asyncState)
+ {
+ if (accept_channel_delegate == null)
+ accept_channel_delegate = new Func<TimeSpan,TChannel> (OnAcceptChannel);
+ return accept_channel_delegate.BeginInvoke (timeout, callback, asyncState);
+ }
+
+ protected override TChannel OnEndAcceptChannel (IAsyncResult result)
+ {
+ if (accept_channel_delegate == null)
+ throw new InvalidOperationException ("Async AcceptChannel operation has not started");
+ return accept_channel_delegate.EndInvoke (result);
+ }
+
+ protected override IAsyncResult OnBeginWaitForChannel (
+ TimeSpan timeout, AsyncCallback callback, object state)
+ {
+ if (wait_delegate == null)
+ wait_delegate = new Func<TimeSpan,bool> (OnWaitForChannel);
+ return wait_delegate.BeginInvoke (timeout, callback, state);
+ }
+
+ protected override bool OnEndWaitForChannel (IAsyncResult result)
+ {
+ if (wait_delegate == null)
+ throw new InvalidOperationException ("Async WaitForChannel operation has not started");
+ return wait_delegate.EndInvoke (result);
+ }
+
+ protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
+ AsyncCallback callback, object state)
+ {
+ if (open_delegate == null)
+ open_delegate = new Action<TimeSpan> (OnOpen);
+ return open_delegate.BeginInvoke (timeout, callback, state);
+ }
+
+ protected override void OnEndOpen (IAsyncResult result)
+ {
+ if (open_delegate == null)
+ throw new InvalidOperationException ("Async Open operation has not started");
+ open_delegate.EndInvoke (result);
+ }
+
+ protected override IAsyncResult OnBeginClose (TimeSpan timeout,
+ AsyncCallback callback, object state)
+ {
+ if (close_delegate == null)
+ close_delegate = new Action<TimeSpan> (OnClose);
+ return close_delegate.BeginInvoke (timeout, callback, state);
+ }
+
+ protected override void OnEndClose (IAsyncResult result)
+ {
+ if (close_delegate == null)
+ throw new InvalidOperationException ("Async Close operation has not started");
+ close_delegate.EndInvoke (result);
+ }
+ }
+
public abstract class ChannelListenerBase<TChannel>
: ChannelListenerBase, IChannelListener<TChannel>,
IChannelListener, ICommunicationObject
}
}
- internal abstract class HttpChannelListenerBase<TChannel> : ChannelListenerBase<TChannel>
+ internal abstract class HttpChannelListenerBase<TChannel> : InternalChannelListenerBase<TChannel>
where TChannel : class, IChannel
{
HttpTransportBindingElement source;
BindingContext context)
: base (context.Binding)
{
- accept_channel_delegate = new Func<TimeSpan,TChannel> (OnAcceptChannel);
// FIXME: consider ListenUriMode
// FIXME: there should be some way to post-provide Uri in case of null listenerUri in context.
protected abstract TChannel CreateChannel (TimeSpan timeout);
- Func<TimeSpan,TChannel> accept_channel_delegate;
-
- protected override IAsyncResult OnBeginAcceptChannel (
- TimeSpan timeout, AsyncCallback callback,
- object asyncState)
- {
- return accept_channel_delegate.BeginInvoke (timeout, callback, asyncState);
- }
-
- protected override TChannel OnEndAcceptChannel (IAsyncResult result)
- {
- return accept_channel_delegate.EndInvoke (result);
- }
-
- protected override IAsyncResult OnBeginWaitForChannel (
- TimeSpan timeout, AsyncCallback callback, object state)
- {
- throw new NotImplementedException ();
- }
-
- protected override bool OnEndWaitForChannel (IAsyncResult result)
- {
- throw new NotImplementedException ();
- }
-
protected override bool OnWaitForChannel (TimeSpan timeout)
{
throw new NotImplementedException ();
}
- protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
- AsyncCallback callback, object state)
- {
- throw new NotImplementedException ();
- }
-
- protected override void OnEndOpen (IAsyncResult result)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- protected override IAsyncResult OnBeginClose (TimeSpan timeout,
- AsyncCallback callback, object state)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- protected override void OnEndClose (IAsyncResult result)
- {
- throw new NotImplementedException ();
- }
-
[MonoTODO ("find out what to do here.")]
protected override void OnAbort ()
{
namespace System.ServiceModel.Channels
{
- internal class TcpChannelListener<TChannel> : ChannelListenerBase<TChannel>
+ internal class TcpChannelListener<TChannel> : InternalChannelListenerBase<TChannel>
where TChannel : class, IChannel
{
List<IChannel> channels = new List<IChannel> ();
throw new NotImplementedException ();
}
- [MonoTODO]
- protected override IAsyncResult OnBeginAcceptChannel (TimeSpan timeout,
- AsyncCallback callback, object asyncState)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- protected override TChannel OnEndAcceptChannel (IAsyncResult result)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- protected override IAsyncResult OnBeginWaitForChannel (
- TimeSpan timeout, AsyncCallback callback, object state)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- protected override bool OnEndWaitForChannel (IAsyncResult result)
- {
- throw new NotImplementedException ();
- }
-
[MonoTODO]
protected override bool OnWaitForChannel (TimeSpan timeout)
{
throw new NotImplementedException ();
}
- [MonoTODO]
- protected override IAsyncResult OnBeginClose (TimeSpan timeout,
- AsyncCallback callback, object state)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- protected override IAsyncResult OnBeginOpen (TimeSpan timeout,
- AsyncCallback callback, object state)
- {
- throw new NotImplementedException ();
- }
-
[MonoTODO]
protected override void OnClose (TimeSpan timeout)
{
tcp_listener = null;
}
- [MonoTODO]
- protected override void OnEndClose (IAsyncResult result)
- {
- throw new NotImplementedException ();
- }
-
- [MonoTODO]
- protected override void OnEndOpen (IAsyncResult result)
- {
- throw new NotImplementedException ();
- }
-
[MonoTODO]
protected override void OnOpen (TimeSpan timeout)
{