2009-05-23 Michael Barker <mike@middlesoft.co.uk>
[mono.git] / mcs / class / Mono.Messaging.RabbitMQ / Mono.Messaging.RabbitMQ / RabbitMQMessageEnumerator.cs
index 93be9fd83fe424c4ec86dec10db6d5b7490a6735..1a05d37146571b7713442966922d8145d1e5d1c1 100644 (file)
@@ -65,6 +65,10 @@ namespace Mono.Messaging.RabbitMQ {
                        }
                }
                
+               public IntPtr CursorHandle {
+                       get { throw new NotImplementedException (); }
+               }
+               
                public void Close ()
                {
                        if (subscription != null) {
@@ -117,7 +121,6 @@ namespace Mono.Messaging.RabbitMQ {
                                if (subscription == null) {
                                        IModel ch = Model;
                                        
-                                       //ushort ticket = ch.AccessRequest ("/data");
                                        string finalName = ch.QueueDeclare (qRef.Queue, false);
                                        
                                        subscription = new Subscription (ch, finalName);
@@ -132,6 +135,12 @@ namespace Mono.Messaging.RabbitMQ {
                        Subscription sub = Subscription;
                        return sub.Next (500, out current);
                }
+               
+               public bool MoveNext (TimeSpan timeout)
+               {
+                       int to = MessageFactory.TimeSpanToInt32 (timeout);
+                       return Subscription.Next (to, out current);
+               }
 
                public IMessage RemoveCurrent ()
                {
@@ -153,6 +162,29 @@ namespace Mono.Messaging.RabbitMQ {
                        throw new NotSupportedException ("Unable to remove messages within a transaction");
                }
                
+               public IMessage RemoveCurrent (TimeSpan timeout)
+               {
+                       // Timeout makes no sense for this implementation, so we just work 
+                       // the same as the non-timeout based one. 
+                       
+                       if (current == null)
+                               throw new InvalidOperationException ();
+                       
+                       IMessage msg = CreateMessage (current);
+                       Subscription.Ack (current);
+                       return msg;
+               }
+               
+               public IMessage RemoveCurrent (TimeSpan timeout, IMessageQueueTransaction transaction)
+               {
+                       throw new NotImplementedException ();
+               }
+               
+               public IMessage RemoveCurrent (TimeSpan timeout, MessageQueueTransactionType transactionType)
+               {
+                       throw new NotImplementedException ();
+               }
+               
                private IMessage CreateMessage (BasicDeliverEventArgs result)
                {
                        return helper.ReadMessage (qRef, result);