Browse Source

2002-08-21 Dietmar Maurer <[email protected]>

	* Exception.cs: set stack_trace to null

	* tcp channel work

svn path=/trunk/mcs/; revision=6852
Dietmar Maurer 23 years ago
parent
commit
6cde095dde

+ 117 - 5
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Tcp/TcpClientChannel.cs

@@ -7,11 +7,92 @@
 //
 
 using System.Collections;
+using System.IO;
 using System.Runtime.Remoting.Messaging;
 using System.Runtime.Remoting.Channels;
+using System.Text.RegularExpressions;
 
 namespace System.Runtime.Remoting.Channels.Tcp
 {
+
+	public class TcpClientTransportSink : IClientChannelSink
+	{
+
+		public TcpClientTransportSink (string url)
+		{
+
+		}
+
+		public IDictionary Properties
+		{
+			get {
+				return null;
+			}
+		}
+
+		public IClientChannelSink NextChannelSink
+		{
+			get {
+				// we are the last one
+				return null;
+			}
+		}
+
+		public void AsyncProcessRequest (IClientChannelSinkStack sinkStack, IMessage msg,
+						 ITransportHeaders headers, Stream stream)
+		{
+			throw new NotImplementedException ();			
+		}
+
+		public void AsyncProcessResponse (IClientResponseChannelSinkStack sinkStack,
+						  object state, ITransportHeaders headers,
+						  Stream stream)
+		{
+			throw new NotImplementedException ();
+		}
+
+		public Stream GetRequestStream (IMessage msg, ITransportHeaders headers)
+		{
+			// no acces to stream?
+			return null;
+		}
+		
+		public void ProcessMessage (IMessage msg,
+					    ITransportHeaders requestHeaders,
+					    Stream requestStream,
+					    out ITransportHeaders responseHeaders,
+					    out Stream responseStream)
+		{
+			throw new NotImplementedException ();
+		}
+			
+	}
+	
+	public class TcpClientTransportSinkProvider : IClientChannelSinkProvider
+	{
+		public TcpClientTransportSinkProvider ()
+		{
+			// what should we do here ?
+		}
+
+		public IClientChannelSinkProvider Next
+		{
+			get {
+				return null;
+			}
+
+			set {
+				// ignore, we are always the last in the chain 
+			}
+		}
+
+		public IClientChannelSink CreateSink (IChannelSender channel, string url,
+						      object remoteChannelData)
+		{
+			return new TcpClientTransportSink (url);
+		}
+	}
+
 	public class TcpClientChannel : IChannelSender, IChannel
 	{
 		int priority = 1;					
@@ -20,13 +101,19 @@ namespace System.Runtime.Remoting.Channels.Tcp
 		
 		public TcpClientChannel ()
 	        {
-			sink_provider = null;
+			sink_provider = new BinaryClientFormatterSinkProvider ();
+			sink_provider.Next = new TcpClientTransportSinkProvider ();
 		}
 
 		public TcpClientChannel (IDictionary properties, IClientChannelSinkProvider sinkProvider)
 		{
 			priority = 1;
 			sink_provider = sinkProvider;
+
+			// add the tcp provider at the end of the chain
+			IClientChannelSinkProvider prov = sinkProvider;
+			while (prov.Next != null) prov = prov.Next;
+			prov.Next = new TcpClientTransportSinkProvider ();
 		}
 
 		public TcpClientChannel (string name, IClientChannelSinkProvider sinkProvider)
@@ -34,6 +121,11 @@ namespace System.Runtime.Remoting.Channels.Tcp
 			priority = 1;		
 			this.name = name;
 			sink_provider = sinkProvider;
+
+			// add the tcp provider at the end of the chain
+			IClientChannelSinkProvider prov = sinkProvider;
+			while (prov.Next != null) prov = prov.Next;
+			prov.Next = new TcpClientTransportSinkProvider ();
 		}
 		
 		public string ChannelName
@@ -50,18 +142,38 @@ namespace System.Runtime.Remoting.Channels.Tcp
 			}
 		}
 
-		[MonoTODO]
 		public IMessageSink CreateMessageSink (string url,
 						       object remoteChannelData,
 						       out string objectURI)
 	        {
-			throw new NotImplementedException ();
+			if (url == null && remoteChannelData != null) {
+				IChannelDataStore ds = remoteChannelData as IChannelDataStore;
+				if (ds != null)
+					url = ds.ChannelUris [0];
+			}
+			
+			if (Parse (url, out objectURI) == null)
+				return null;
+
+			return (IMessageSink) sink_provider.CreateSink (this, url, remoteChannelData);
 		}
 
-		[MonoTODO]
 		public string Parse (string url, out string objectURI)
 		{
-			throw new NotImplementedException ();
+			// format: "tcp://host:port/path/to/object"
+			
+			objectURI = null;
+			
+			Match m = Regex.Match (url, "tcp://([^:]+):([0-9]+)(/.*)");
+
+			if (!m.Success)
+				return null;
+			
+			string host = m.Groups[1].Value;
+			string port = m.Groups[2].Value;
+			objectURI = m.Groups[3].Value;
+			
+			return "tcp://" + host + ":" + port;
 		}
 
 	}

+ 24 - 9
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSink.cs

@@ -2,6 +2,7 @@
 // System.Runtime.Remoting.Channels.BinaryClientFormatterSink.cs
 //
 // Author: Rodrigo Moya ([email protected])
+//         Dietmar Maurer ([email protected])
 //
 // 2002 (C) Copyright, Ximian, Inc.
 //
@@ -31,14 +32,16 @@ namespace System.Runtime.Remoting.Channels
 
 		public IMessageSink NextSink
 		{
-			[MonoTODO]
-				get { throw new NotImplementedException (); }
+			get {
+				return (IMessageSink) nextInChain;
+			}
 		}
 
 		public IDictionary Properties
 		{
-			[MonoTODO]
-				get { throw new NotImplementedException (); }
+			get {
+				return null;
+			}
 		}
 
 		[MonoTODO]
@@ -66,27 +69,39 @@ namespace System.Runtime.Remoting.Channels
 			throw new NotImplementedException ();
 		}
 
-		[MonoTODO]
 		public Stream GetRequestStream (IMessage msg,
 						ITransportHeaders headers)
 		{
-			throw new NotImplementedException ();
+			return null;
 		}
 
-		[MonoTODO]
 		public void ProcessMessage (IMessage msg,
 					    ITransportHeaders requestHeaders,
 					    Stream requestStream,
 					    out ITransportHeaders responseHeaders,
 					    out Stream responseStream)
 		{
-			throw new NotImplementedException ();
+			nextInChain.ProcessMessage (msg, requestHeaders, requestStream,
+						    out responseHeaders, out responseStream);
 		}
 
 		[MonoTODO]
 		public IMessage SyncProcessMessage (IMessage msg)
 		{
-			throw new NotImplementedException ();
+			ITransportHeaders response_headers;
+			Stream response_stream;
+			
+			// fixme: use nextInChain.GetRequestStream() ??
+			Stream out_stream = new MemoryStream ();
+
+			// fixme: serialize msg to the stream
+
+			ProcessMessage (msg, null, out_stream, out response_headers, out response_stream);
+
+			// fixme: deserialize response_stream
+			IMessage result = null;
+
+			return null;
 		}
 	}
 }

+ 21 - 8
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryClientFormatterSinkProvider.cs

@@ -13,31 +13,44 @@ namespace System.Runtime.Remoting.Channels
 	public class BinaryClientFormatterSinkProvider :
 		IClientFormatterSinkProvider, IClientChannelSinkProvider
 	{
-		[MonoTODO]
+		IClientChannelSinkProvider next = null;
+
+		// this is not used at the moment ??
+		IDictionary properties;
+		
 		public BinaryClientFormatterSinkProvider ()
 		{
-			throw new NotImplementedException ();
+			properties = new Hashtable ();
 		}
 
-		[MonoTODO]
 		public BinaryClientFormatterSinkProvider (IDictionary properties,
 							  ICollection providerData)
 	        {
-			throw new NotImplementedException ();
+			this.properties = properties;
+			// fixme: what shall we do with providerData?
 		}
 
 		public IClientChannelSinkProvider Next
 		{
-			get { throw new NotImplementedException (); }
-			set { throw new NotImplementedException (); }
+			get {
+				return next;
+			}
+			
+			set {
+				next = value;
+			}
 		}
 
-		[MonoTODO]
 		public IClientChannelSink CreateSink (IChannelSender channel,
 						      string url,
 						      object remoteChannelData)
 		{
-			throw new NotImplementedException ();
+			IClientChannelSink next_sink = null;
+
+			if (next != null)
+				next_sink = next.CreateSink (channel, url, remoteChannelData);
+			
+			return new BinaryClientFormatterSink (next_sink);
 		}		
 	}
 }

+ 3 - 0
mcs/class/corlib/System/ChangeLog

@@ -1,3 +1,6 @@
+2002-08-21  Dietmar Maurer  <[email protected]>
+
+	* Exception.cs: set stack_trace to null
 
 Wed Aug 21 13:02:20 CEST 2002 Paolo Molaro <[email protected]>
 

+ 1 - 1
mcs/class/corlib/System/Exception.cs

@@ -21,7 +21,7 @@ namespace System {
 		string message;
 		string help_link;
 		string class_name;
-		string stack_trace = "TODO: implement stack traces";
+		string stack_trace = null;
 		string remote_stack_trace = "TODO: Implement remote stack trace";
 		int remote_stack_index;
 		int hresult;