activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1555261 - in /activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands: PUBLISH.cs PUBREC.cs PUBREL.cs
Date Fri, 03 Jan 2014 21:51:05 GMT
Author: tabish
Date: Fri Jan  3 21:51:05 2014
New Revision: 1555261

URL: http://svn.apache.org/r1555261
Log:
https://issues.apache.org/jira/browse/AMQNET-458

Add more to Commands code.

Modified:
    activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBLISH.cs
    activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREC.cs
    activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREL.cs

Modified: activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBLISH.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBLISH.cs?rev=1555261&r1=1555260&r2=1555261&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBLISH.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBLISH.cs Fri
Jan  3 21:51:05 2014
@@ -16,6 +16,7 @@
 //
 using System;
 using System.IO;
+using System.Text;
 using Apache.NMS.MQTT.Transport;
 using Apache.NMS.MQTT.Protocol;
 
@@ -32,11 +33,19 @@ namespace Apache.NMS.MQTT.Commands
 	/// </summary>
 	public class PUBLISH : BaseCommand
 	{
+        public enum QOS
+        {
+            QOS_AT_MOST_ONCE,
+            QOS_AT_LEAST_ONCE,
+            QOS_EXACTLY_ONCE
+        };
+
 		public const byte TYPE = 3;
 		public const byte DEFAULT_HEADER = 0x30;
 
 		public PUBLISH() : base(new Header(DEFAULT_HEADER))
 		{
+            QoSLevel = (int)QOS.QOS_AT_LEAST_ONCE;
 		}
 
 		public PUBLISH(Header header) : base(header)
@@ -94,6 +103,41 @@ namespace Apache.NMS.MQTT.Commands
 			get { return this.payload; }
 			set { this.payload = value; }
 		}
+
+        public override void Encode(BinaryWriter writer)
+        {
+            writer.Write(topicName);
+
+            if (QoSLevel == (int)QOS.QOS_AT_MOST_ONCE)
+            {
+                writer.Write(messageId);
+            }
+
+            if (payload != null && payload.Length != 0)
+            {
+                writer.Write(payload);
+            }
+        }
+
+        public override void Decode(BinaryReader reader)
+        {
+            TopicName = reader.ReadString();
+
+            if (QoSLevel == (int)QOS.QOS_AT_MOST_ONCE)
+            {
+                MessageId = reader.ReadInt16();
+            }
+
+            MemoryStream stream = reader.BaseStream as MemoryStream;
+
+            long size = stream.Length - stream.Position;
+
+            byte[] buffer = new byte[size];
+            for (long i = 0; i < size; ++i)
+            {
+                buffer[i] = (byte)stream.ReadByte();
+            }
+        }
 	}
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREC.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREC.cs?rev=1555261&r1=1555260&r2=1555261&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREC.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREC.cs Fri
Jan  3 21:51:05 2014
@@ -21,7 +21,7 @@ using Apache.NMS.MQTT.Protocol;
 
 namespace Apache.NMS.MQTT.Commands
 {
-	public class PUBREC : BaseCommand
+	public class PUBREC : Response
 	{
 		public const byte TYPE = 5;
 		public const byte DEFAULT_HEADER = 0x50;
@@ -43,6 +43,16 @@ namespace Apache.NMS.MQTT.Commands
 		{
 			get { return true; }
 		}
+
+        public override void Encode(BinaryWriter writer)
+        {
+            writer.Write(CommandId);
+        }
+
+        public override void Decode(BinaryReader reader)
+        {
+            CorrelationId = reader.ReadInt16();
+        }
 	}
 }
 

Modified: activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREL.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREL.cs?rev=1555261&r1=1555260&r2=1555261&view=diff
==============================================================================
--- activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREL.cs (original)
+++ activemq/activemq-dotnet/Apache.NMS.MQTT/trunk/src/main/csharp/Commands/PUBREL.cs Fri
Jan  3 21:51:05 2014
@@ -21,7 +21,7 @@ using Apache.NMS.MQTT.Protocol;
 
 namespace Apache.NMS.MQTT.Commands
 {
-	public class PUBREL : BaseCommand
+	public class PUBREL : Response
 	{
 		public const byte TYPE = 6;
 		public const byte DEFAULT_HEADER = 0x62;
@@ -43,6 +43,16 @@ namespace Apache.NMS.MQTT.Commands
 		{
 			get { return true; }
 		}
+
+        public override void Encode(BinaryWriter writer)
+        {
+            writer.Write(CommandId);
+        }
+
+        public override void Decode(BinaryReader reader)
+        {
+            CorrelationId = reader.ReadInt16();
+        }
 	}
 }
 



Mime
View raw message