activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r512781 - in /activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp: StompFrameStream.cs StompWireFormat.cs
Date Wed, 28 Feb 2007 14:52:20 GMT
Author: jstrachan
Date: Wed Feb 28 06:52:19 2007
New Revision: 512781

URL: http://svn.apache.org/viewvc?view=rev&rev=512781
Log:
fixed the NMS Stomp test cases finally

Modified:
    activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompFrameStream.cs
    activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompFrameStream.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompFrameStream.cs?view=diff&rev=512781&r1=512780&r2=512781
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompFrameStream.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompFrameStream.cs
Wed Feb 28 06:52:19 2007
@@ -54,10 +54,10 @@
 			set { content = value; }
 		}
 		
-		public int ContentLength 
+		public int ContentLength
 		{
 			get { return contentLength; }
-			set 
+			set
 			{
 				contentLength = value;
 				WriteHeader("content-length", contentLength);
@@ -84,18 +84,28 @@
 			}
 		}
 		
+		public void WriteHeader(String name, bool value)
+		{
+			if (value) {
+				builder.Append(name);
+				builder.Append(SEPARATOR);
+				builder.Append("true");
+				builder.Append(NEWLINE);
+			}
+		}
+		
 		public void Flush()
 		{
 			builder.Append(NEWLINE);
 			ds.Write(encoding.GetBytes(builder.ToString()));
 			
-			if (content != null) 
+			if (content != null)
 			{
 				ds.Write(content);
 			}
 			
 			// if no content length then lets write a null
-			if (contentLength < 0) 
+			if (contentLength < 0)
 			{
 				ds.Write(NULL);
 			}

Modified: activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs
URL: http://svn.apache.org/viewvc/activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs?view=diff&rev=512781&r1=512780&r2=512781
==============================================================================
--- activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs
(original)
+++ activemq/activemq-dotnet/trunk/src/main/csharp/ActiveMQ/Transport/Stomp/StompWireFormat.cs
Wed Feb 28 06:52:19 2007
@@ -53,7 +53,7 @@
 			//Console.Out.Flush();
 			StompFrameStream ds = new StompFrameStream(binaryWriter, encoding);
 			
-			if (o is ConnectionInfo) 
+			if (o is ConnectionInfo)
 			{
 				WriteConnectionInfo((ConnectionInfo) o, ds);
 			}
@@ -69,17 +69,17 @@
 			{
 				WriteMessageAck((MessageAck) o, ds);
 			}
-			else if (o is Command) 
+			else if (o is Command)
 			{
 				Command command = o as Command;
-				if (command.ResponseRequired) 
+				if (command.ResponseRequired)
 				{
 					Response response = new Response();
-					response.CorrelationId = command.CommandId; 
+					response.CorrelationId = command.CommandId;
 					SendCommand(response);
 				}
 			}
-			else 
+			else
 			{
 				Console.WriteLine("Ignored command: " + o);
 			}
@@ -98,10 +98,10 @@
 			
 			IDictionary headers = new Hashtable();
 			string line;
-			while((line = socketReader.ReadLine()) != "") 
+			while((line = socketReader.ReadLine()) != "")
 			{
 				int idx = line.IndexOf(':');
-				if (idx > 0) 
+				if (idx > 0)
 				{
 					string key = line.Substring(0, idx);
 					string value = line.Substring(idx + 1);
@@ -109,14 +109,14 @@
 					
 					Console.WriteLine(">> header: " + key + " = " + value);
 				}
-				else 
+				else
 				{
 					// lets ignore this bad header!
 				}
 			}
 			byte[] content = null;
 			string length = ToString(headers["content-length"]);
-			if (length != null) 
+			if (length != null)
 			{
 				int size = Int32.Parse(length);
 				content = dis.ReadBytes(size);
@@ -125,7 +125,7 @@
 			{
 				StringBuilder body = new StringBuilder();
 				int nextChar;
-				while((nextChar = socketReader.Read()) != 0) 
+				while((nextChar = socketReader.Read()) != 0)
 				{
 					body.Append((char)nextChar);
 				}
@@ -138,23 +138,23 @@
 			return answer;
         }
 
-		protected Object CreateCommand(string command, IDictionary headers, byte[] content) 
+		protected Object CreateCommand(string command, IDictionary headers, byte[] content)
 		{
 			if (command == "RECEIPT" || command == "CONNECTED")
 			{
 				Response answer = new Response();
 				string text = RemoveHeader(headers, "receipt-id");
-				if (text != null) 
+				if (text != null)
 				{
 					answer.CorrelationId = Int32.Parse(text);
 				}
-				return answer; 
+				return answer;
 			}
 			else if (command == "ERROR")
 			{
 				ExceptionResponse answer = new ExceptionResponse();
 				string text = RemoveHeader(headers, "receipt-id");
-				if (text != null) 
+				if (text != null)
 				{
 					answer.CorrelationId = Int32.Parse(text);
 				}
@@ -163,7 +163,7 @@
 				error.Message = RemoveHeader(headers, "message");
 				error.ExceptionClass = RemoveHeader(headers, "exceptionClass"); // TODO is this the right
header?
 				answer.Exception = error;
-				return answer; 
+				return answer;
 			}
 			else if (command == "MESSAGE")
 			{
@@ -176,7 +176,7 @@
 			}
 		}
 		
-		protected Command ReadMessage(string command, IDictionary headers, byte[] content) 
+		protected Command ReadMessage(string command, IDictionary headers, byte[] content)
 		{
 			ActiveMQMessage message = null;
 			if (headers.Contains("content-length"))
@@ -184,7 +184,7 @@
 				message = new ActiveMQBytesMessage();
 				message.Content = content;
 			}
-			else 
+			else
 			{
 				message = new ActiveMQTextMessage(encoding.GetString(content, 0, content.Length));
 			}
@@ -220,7 +220,16 @@
 			// now lets add the generic headers
 			foreach (string key in headers.Keys)
 			{
-				message.Properties[key] = headers[key];
+				Object value = headers[key];
+				if (value != null)
+				{
+					// lets coerce some standard header extensions
+					if (key == "NMSXGroupSeq")
+					{
+						value = Int32.Parse(value.ToString());
+					}
+				}
+				message.Properties[key] = value;
 			}
 			MessageDispatch dispatch = new MessageDispatch();
 			dispatch.Message = message;
@@ -280,12 +289,12 @@
 			// lets force the content to be marshalled
 			
 			command.BeforeMarshall(null);
-			if (command is ActiveMQTextMessage) 
+			if (command is ActiveMQTextMessage)
 			{
 				ActiveMQTextMessage textMessage = command as ActiveMQTextMessage;
 				ss.Content = encoding.GetBytes(textMessage.Text);
 			}
-			else 
+			else
 			{
 				ss.Content = command.Content;
 				ss.ContentLength = command.Content.Length;
@@ -316,7 +325,7 @@
 			{
 				Console.WriteLine("No transport configured so cannot return command: " + command);
 			}
-			else 
+			else
 			{
 				transport.Command(transport, command);
 			}
@@ -325,11 +334,11 @@
 		protected string RemoveHeader(IDictionary headers, string name)
 		{
 			object value = headers[name];
-			if (value == null) 
+			if (value == null)
 			{
 				return null;
 			}
-			else 
+			else
 			{
 				headers.Remove(name);
 				return value.ToString();
@@ -337,13 +346,13 @@
 		}
 		
 		
-		protected string ToString(object value) 
+		protected string ToString(object value)
 		{
-			if (value != null) 
+			if (value != null)
 			{
 				return value.ToString();
 			}
-			else 
+			else
 			{
 				return null;
 			}



Mime
View raw message