Skip to content
Permalink
Browse files
  • Loading branch information
Timothy A. Bish committed Jan 20, 2011
1 parent 1c485d9 commit 9991a4d73e9ef02ee6c2a8b532ae5e295119facc
Showing 1 changed file with 18 additions and 7 deletions.
@@ -32,6 +32,7 @@ public class StompWireFormat : IWireFormat
private IPrimitiveMapMarshaler mapMarshaler = new XmlPrimitiveMapMarshaler();
private ITransport transport;
private WireFormatInfo remoteWireFormatInfo;
private int connectedResponseId = -1;

public StompWireFormat()
{
@@ -190,8 +191,6 @@ protected virtual Object CreateCommand(StompFrame frame)

protected virtual Command ReadConnected(StompFrame frame)
{
string responseId = frame.RemoveProperty("response-id");

this.remoteWireFormatInfo = new WireFormatInfo();

if(frame.HasProperty("version"))
@@ -222,11 +221,16 @@ protected virtual Command ReadConnected(StompFrame frame)
remoteWireFormatInfo.Version = 1.0f;
}

if(responseId != null)
if(this.connectedResponseId != -1)
{
Response answer = new Response();
answer.CorrelationId = Int32.Parse(responseId);
answer.CorrelationId = this.connectedResponseId;
SendCommand(answer);
this.connectedResponseId = -1;
}
else
{
throw new IOException("Received Connected Frame without a set Response Id for it.");
}

return remoteWireFormatInfo;
@@ -442,9 +446,14 @@ protected virtual void WriteConnectionInfo(ConnectionInfo command, BinaryWriter
StompFrame frame = new StompFrame("CONNECT");

frame.SetProperty("client-id", command.ClientId);
frame.SetProperty("login", command.UserName);
frame.SetProperty("passcode", command.Password);
frame.SetProperty("request-id", command.CommandId);
if(!String.IsNullOrEmpty(command.UserName))
{
frame.SetProperty("login", command.UserName);
}
if(!String.IsNullOrEmpty(command.Password))
{
frame.SetProperty("passcode", command.Password);
}
frame.SetProperty("host", command.Host);
frame.SetProperty("accept-version", "1.0,1.1");

@@ -458,6 +467,8 @@ protected virtual void WriteConnectionInfo(ConnectionInfo command, BinaryWriter
Tracer.Debug("StompWireFormat - Writing " + frame.ToString());
}

this.connectedResponseId = command.CommandId;

frame.ToStream(dataOut);
}

0 comments on commit 9991a4d

Please sign in to comment.