Skip to content

Commit 1a1e3ab

Browse files
author
Vlad Ionescu
committed
merging from default
2 parents 5ebb15d + b68ac2c commit 1a1e3ab

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

projects/client/RabbitMQ.Client/src/client/api/ConnectionFactory.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ namespace RabbitMQ.Client
8080
/// factory.VirtualHost = ConnectionFactory.DefaultVHost;
8181
/// factory.Protocol = Protocols.FromEnvironment();
8282
/// factory.HostName = hostName;
83-
// factory.PortNumber = AmqpTcpEndpoint.UseDefaultPort;
83+
/// factory.PortNumber = AmqpTcpEndpoint.UseDefaultPort;
8484
/// //
8585
/// IConnection conn = factory.CreateConnection();
8686
/// //
@@ -144,6 +144,10 @@ public class ConnectionFactory
144144
/// <summary>Heartbeat setting to request (in seconds)</summary>
145145
public ushort RequestedHeartbeat = DefaultHeartbeat;
146146

147+
/// <summary>Dictionary of client properties to be sent to the
148+
/// server</summary>
149+
public IDictionary ClientProperties = ConnectionBase.DefaultClientProperties();
150+
147151
///<summary>Ssl options setting</summary>
148152
public SslOption Ssl = new SslOption();
149153

projects/client/RabbitMQ.Client/src/client/api/IConnection.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ public interface IConnection: IDisposable
116116
///(0 for disabled), in seconds.</summary>
117117
ushort Heartbeat { get; }
118118

119+
///<summary>A copy of the client properties that has been sent to the
120+
///server.</summary>
121+
IDictionary ClientProperties { get; }
122+
123+
///<summary>A dictionary of the server properties sent by the server
124+
///while establishing the connection. This typically includes
125+
///the product name and version of the server.</summary>
126+
IDictionary ServerProperties { get; }
127+
119128
///<summary>Returns the known hosts that came back from the
120129
///broker in the connection.open-ok method at connection
121130
///startup time. Null until the connection is completely open

projects/client/RabbitMQ.Client/src/client/impl/ConnectionBase.cs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ public abstract class ConnectionBase : IConnection
9494
public IFrameHandler m_frameHandler;
9595
public uint m_frameMax = 0;
9696
public ushort m_heartbeat = 0;
97+
public IDictionary m_clientProperties;
98+
public IDictionary m_serverProperties;
9799
public AmqpTcpEndpoint[] m_knownHosts = null;
98100

99101
public MainSession m_session0;
@@ -251,6 +253,30 @@ public ushort Heartbeat
251253
}
252254
}
253255

256+
public IDictionary ClientProperties
257+
{
258+
get
259+
{
260+
return new Hashtable(m_clientProperties);
261+
}
262+
set
263+
{
264+
m_clientProperties = value;
265+
}
266+
}
267+
268+
public IDictionary ServerProperties
269+
{
270+
get
271+
{
272+
return m_serverProperties;
273+
}
274+
set
275+
{
276+
m_serverProperties = value;
277+
}
278+
}
279+
254280
public AmqpTcpEndpoint[] KnownHosts
255281
{
256282
get { return m_knownHosts; }
@@ -905,9 +931,11 @@ public void OnCallbackException(CallbackExceptionEventArgs args)
905931
}
906932
}
907933

908-
public IDictionary BuildClientPropertiesTable()
934+
public static IDictionary DefaultClientProperties()
909935
{
910-
string version = this.GetType().Assembly.GetName().Version.ToString();
936+
System.Reflection.Assembly assembly =
937+
System.Reflection.Assembly.GetAssembly(typeof(ConnectionBase));
938+
string version = assembly.GetName().Version.ToString();
911939
//TODO: Get the rest of this data from the Assembly Attributes
912940
Hashtable table = new Hashtable();
913941
table["product"] = Encoding.UTF8.GetBytes("RabbitMQ");
@@ -950,6 +978,8 @@ public void Open(bool insist)
950978
ConnectionStartDetails connectionStart = (ConnectionStartDetails)
951979
connectionStartCell.Value;
952980

981+
ServerProperties = connectionStart.m_serverProperties;
982+
953983
AmqpVersion serverVersion = new AmqpVersion(connectionStart.m_versionMajor,
954984
connectionStart.m_versionMinor);
955985
if (!serverVersion.Equals(Protocol.Version))
@@ -962,10 +992,12 @@ public void Open(bool insist)
962992
serverVersion.Minor);
963993
}
964994

995+
m_clientProperties = new Hashtable(m_factory.ClientProperties);
996+
965997
// FIXME: check that PLAIN is supported.
966998
// FIXME: parse out locales properly!
967999
ConnectionTuneDetails connectionTune =
968-
m_model0.ConnectionStartOk(BuildClientPropertiesTable(),
1000+
m_model0.ConnectionStartOk(m_clientProperties,
9691001
"PLAIN",
9701002
Encoding.UTF8.GetBytes("\0" + m_factory.UserName +
9711003
"\0" + m_factory.Password),

0 commit comments

Comments
 (0)