2009-04-27 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Mon, 27 Apr 2009 15:56:10 +0000 (15:56 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Mon, 27 Apr 2009 15:56:10 +0000 (15:56 -0000)
* TcpDuplexSessionChannel.cs : implemented some channel methods.

svn path=/trunk/mcs/; revision=132757

mcs/class/System.ServiceModel/System.ServiceModel.Channels/ChangeLog
mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpDuplexSessionChannel.cs

index c35c20630a324de0c7601dec123025a191fab415..8935006dce51c2d5315b62179589c18a259bb1af 100755 (executable)
@@ -1,3 +1,7 @@
+2009-04-27  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * TcpDuplexSessionChannel.cs : implemented some channel methods.
+
 2009-04-27  Atsushi Enomoto  <atsushi@ximian.com>
 
        * BinaryMessageEncoder.cs : use XmlDictionary specified as [MC-NBFS].
index 9aa19bc1e4001e2d9563dd5b3e4391d4a3da81ef..383e8bf18ed580f4e0a1864650e714448f9b4726 100644 (file)
@@ -20,7 +20,6 @@ namespace System.ServiceModel.Channels
 {
        internal class TcpDuplexSessionChannel : DuplexChannelBase, IDuplexSessionChannel
        {
-
                TcpChannelInfo info;
                TcpClient client;
                bool is_service_side;
@@ -93,9 +92,14 @@ namespace System.ServiceModel.Channels
                        throw new NotImplementedException ();
                }
 
-               [MonoTODO]
                public override void Send (Message message)
                {
+                       Send (message, DefaultSendTimeout);
+               }
+               
+               public override void Send (Message message, TimeSpan timeout)
+               {
+                       client.SendTimeout = (int) timeout.TotalMilliseconds;
                        MemoryStream ms = new MemoryStream ();
                        BinaryFormatter bf = new BinaryFormatter ();
                        
@@ -117,12 +121,6 @@ namespace System.ServiceModel.Channels
                        }
                }
                
-               [MonoTODO]
-               public override void Send (Message message, TimeSpan timeout)
-               {
-                       throw new NotImplementedException ();
-               }
-               
                [MonoTODO]
                public override IAsyncResult BeginReceive (AsyncCallback callback, object state)
                {
@@ -165,14 +163,21 @@ namespace System.ServiceModel.Channels
                        throw new NotImplementedException ();
                }
                
-               [MonoTODO]
                public override Message Receive ()
                {
+                       return Receive (DefaultReceiveTimeout);
+               }
+               
+               public override Message Receive (TimeSpan timeout)
+               {
+                       client.ReceiveTimeout = (int) timeout.TotalMilliseconds;
                        Stream s = client.GetStream ();
                        s.ReadByte (); // 6
                        MyBinaryReader br = new MyBinaryReader (s);
 //                     string msg = br.ReadString ();
 //                     br.Read7BitEncodedInt ();
+
+                       // FIXME: implement [MC-NMF] correctly. Currently it is a guessed protocol hack.
                        byte [] buffer = new byte [65536];
                        buffer = br.ReadBytes ();
                        MemoryStream ms = new MemoryStream ();
@@ -193,22 +198,26 @@ namespace System.ServiceModel.Channels
                        return msg;
                }
                
-               [MonoTODO]
-               public override Message Receive (TimeSpan timeout)
-               {
-                       throw new NotImplementedException ();
-               }
-               
-               [MonoTODO]
                public override bool TryReceive (TimeSpan timeout, out Message message)
                {
-                       throw new NotImplementedException ();
+                       try {
+                               message = Receive (timeout);
+                               return true;
+                       } catch (TimeoutException) {
+                               message = null;
+                               return false;
+                       }
                }
                
-               [MonoTODO]
                public override bool WaitForMessage (TimeSpan timeout)
                {
-                       throw new NotImplementedException ();
+                       client.ReceiveTimeout = (int) timeout.TotalMilliseconds;
+                       try {
+                               client.GetStream ();
+                               return true;
+                       } catch (TimeoutException) {
+                               return false;
+                       }
                }
                
                // CommunicationObject