Ver Fonte

2009-06-18 Atsushi Enomoto <[email protected]>

	* HttpChannelListener.cs, HttpListenerManager.cs :
	  slightly improved BuildChannelListener().
	  Implement OnAbort() and differentiate it from OnClose().


svn path=/trunk/mcs/; revision=136406
Atsushi Eno há 16 anos atrás
pai
commit
8a843924f5

+ 6 - 0
mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog

@@ -1,3 +1,9 @@
+2009-06-18  Atsushi Enomoto  <[email protected]>
+
+	* HttpChannelListener.cs, HttpListenerManager.cs :
+	  slightly improved BuildChannelListener().
+	  Implement OnAbort() and differentiate it from OnClose().
+
 2009-06-18  Atsushi Enomoto  <[email protected]>
 
 	* TcpDuplexSessionChannel.cs : remove NIE stubs.

+ 17 - 5
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpChannelListener.cs

@@ -56,9 +56,11 @@ namespace System.ServiceModel.Channels
 		{
 			if (typeof (TChannel) == typeof (IReplyChannel))
 				return (TChannel) (object) new HttpSimpleReplyChannel ((HttpSimpleChannelListener<IReplyChannel>) (object) this);
+			// FIXME: session channel support
+			if (typeof (TChannel) == typeof (IReplySessionChannel))
+				throw new NotImplementedException ();
 
-			// FIXME: implement more
-			throw new NotImplementedException ();
+			throw new NotSupportedException (String.Format ("Channel type {0} is not supported", typeof (TChannel)));
 		}
 
 		protected override void OnOpen (TimeSpan timeout)
@@ -67,12 +69,20 @@ namespace System.ServiceModel.Channels
 			StartListening (timeout);
 		}
 
+		protected override void OnAbort ()
+		{
+			httpChannelManager.Stop (true);
+		}
+
 		protected override void OnClose (TimeSpan timeout)
 		{
 			if (State == CommunicationState.Closed)
 				return;
 			base.OnClose (timeout);
-			httpChannelManager.Stop ();
+			// FIXME: it is said that channels are not closed
+			// when the channel listener is closed.
+			// http://blogs.msdn.com/drnick/archive/2006/03/22/557642.aspx
+			httpChannelManager.Stop (false);
 		}
 
 		void StartListening (TimeSpan timeout)
@@ -95,9 +105,11 @@ namespace System.ServiceModel.Channels
 		{
 			if (typeof (TChannel) == typeof (IReplyChannel))
 				return (TChannel) (object) new AspNetReplyChannel ((AspNetChannelListener<IReplyChannel>) (object) this);
+			// FIXME: session channel support
+			if (typeof (TChannel) == typeof (IReplySessionChannel))
+				throw new NotImplementedException ();
 
-			// FIXME: implement more
-			throw new NotImplementedException ();
+			throw new NotSupportedException (String.Format ("Channel type {0} is not supported", typeof (TChannel)));
 		}
 	}
 

+ 7 - 3
mcs/class/System.ServiceModel/System.ServiceModel.Channels/HttpListenerManager.cs

@@ -72,7 +72,7 @@ namespace System.ServiceModel.Channels
 			}
 		}
 
-		public void Stop ()
+		public void Stop (bool abort)
 		{
 			lock (opened_listeners) {
 				if (http_listener == null)
@@ -80,8 +80,12 @@ namespace System.ServiceModel.Channels
 				List<HttpSimpleChannelListener<TChannel>> channelsList = registered_channels [channel_listener.Uri];
 				channelsList.Remove (channel_listener);
 				if (channelsList.Count == 0) {
-					if (http_listener.IsListening)
-						http_listener.Stop ();
+					if (http_listener.IsListening) {
+						if (abort)
+							http_listener.Abort ();
+						else
+							http_listener.Close ();
+					}
 					((IDisposable) http_listener).Dispose ();
 
 					opened_listeners.Remove (channel_listener.Uri);