45
45
46
46
namespace RabbitMQ . Client
47
47
{
48
- ///<summary>Represents a TCP-addressable AMQP peer, including the
49
- ///protocol variant to use, and a host name and port
48
+ ///<summary>Represents a TCP-addressable AMQP peer: a host name and port
50
49
///number.</summary>
51
50
///<para>
52
51
/// Some of the constructors take, as a convenience, a System.Uri
@@ -62,12 +61,10 @@ public class AmqpTcpEndpoint
62
61
public const int DefaultAmqpSslPort = 5671 ;
63
62
public const int UseDefaultPort = - 1 ;
64
63
65
- private IProtocol m_protocol ;
66
- ///<summary>Retrieve or set the IProtocol of this AmqpTcpEndpoint.</summary>
64
+ ///<summary>Retrieve IProtocol of this AmqpTcpEndpoint.</summary>
67
65
public IProtocol Protocol
68
66
{
69
- get { return m_protocol ; }
70
- set { m_protocol = value ; }
67
+ get { return Protocols . DefaultProtocol ; }
71
68
}
72
69
73
70
private string m_hostName ;
@@ -81,15 +78,15 @@ public string HostName
81
78
private int m_port ;
82
79
///<summary>Retrieve or set the port number of this
83
80
///AmqpTcpEndpoint. A port number of -1 causes the default
84
- ///port number for the IProtocol to be used .</summary>
81
+ ///port number.</summary>
85
82
public int Port
86
83
{
87
84
get {
88
85
if ( m_port != UseDefaultPort )
89
86
return m_port ;
90
87
if ( m_ssl . Enabled )
91
88
return DefaultAmqpSslPort ;
92
- return m_protocol . DefaultPort ;
89
+ return Protocol . DefaultPort ;
93
90
}
94
91
set { m_port = value ; }
95
92
}
@@ -105,100 +102,56 @@ public SslOption Ssl
105
102
}
106
103
107
104
///<summary>Construct an AmqpTcpEndpoint with the given
108
- ///IProtocol, hostname, port number and ssl option. If the port
109
- ///number is -1, the default port number for the IProtocol
110
- ///will be used.</summary>
111
- public AmqpTcpEndpoint ( IProtocol protocol , string hostName , int portOrMinusOne , SslOption ssl )
105
+ ///hostname, port number and ssl option. If the port
106
+ ///number is -1, the default port number will be used.</summary>
107
+ public AmqpTcpEndpoint ( string hostName , int portOrMinusOne , SslOption ssl )
112
108
{
113
- m_protocol = protocol ;
114
109
m_hostName = hostName ;
115
110
m_port = portOrMinusOne ;
116
111
m_ssl = ssl ;
117
112
}
118
113
119
114
///<summary>Construct an AmqpTcpEndpoint with the given
120
- ///IProtocol, hostname, and port number. If the port number is
121
- ///-1, the default port number for the IProtocol will be
122
- ///used.</summary>
123
- public AmqpTcpEndpoint ( IProtocol protocol , string hostName , int portOrMinusOne ) :
124
- this ( protocol , hostName , portOrMinusOne , new SslOption ( ) )
125
- {
126
- }
127
-
128
- ///<summary>Construct an AmqpTcpEndpoint with the given
129
- ///IProtocol and hostname, using the default port for the
130
- ///IProtocol.</summary>
131
- public AmqpTcpEndpoint ( IProtocol protocol , string hostName ) :
132
- this ( protocol , hostName , - 1 )
133
- {
134
- }
135
-
136
- ///<summary>Construct an AmqpTcpEndpoint with the given
137
- ///IProtocol, "localhost" as the hostname, and using the
138
- ///default port for the IProtocol.</summary>
139
- public AmqpTcpEndpoint ( IProtocol protocol ) :
140
- this ( protocol , "localhost" , - 1 )
141
- {
142
- }
143
-
144
- ///<summary>Construct an AmqpTcpEndpoint with the given
145
- ///hostname and port number, using Protocols.DefaultProtocol. If the port number is
146
- ///-1, the default port number for the IProtocol will be
115
+ ///hostname, and port number. If the port number is
116
+ ///-1, the default port number will be
147
117
///used.</summary>
148
118
public AmqpTcpEndpoint ( string hostName , int portOrMinusOne ) :
149
- this ( Protocols . DefaultProtocol , hostName , portOrMinusOne )
119
+ this ( hostName , portOrMinusOne , new SslOption ( ) )
150
120
{
151
121
}
152
122
153
123
///<summary>Construct an AmqpTcpEndpoint with the given
154
- ///hostname, using the IProtocol from
155
- ///Protocols.DefaultProtocol, and the default port number of
156
- ///that IProtocol.</summary>
124
+ ///hostname, using the default port.</summary>
157
125
public AmqpTcpEndpoint ( string hostName ) :
158
- this ( Protocols . DefaultProtocol , hostName )
126
+ this ( hostName , - 1 )
159
127
{
160
128
}
161
129
162
- ///<summary>Construct an AmqpTcpEndpoint with a hostname of
163
- ///"localhost", using the IProtocol from
164
- ///Protocols.DefaultProtocol, and the default port number of
165
- ///that IProtocol.</summary>
130
+ ///<summary>Construct an AmqpTcpEndpoint with "localhost" as
131
+ ///the hostname, and using the default port.</summary>
166
132
public AmqpTcpEndpoint ( ) :
167
- this ( Protocols . DefaultProtocol )
133
+ this ( "localhost" , - 1 )
168
134
{
169
135
}
170
136
171
137
///<summary>Construct an AmqpTcpEndpoint with the given
172
- ///IProtocol, Uri and ssl options.</summary>
138
+ ///Uri and ssl options.</summary>
173
139
///<remarks>
174
140
/// Please see the class overview documentation for
175
141
/// information about the Uri format in use.
176
142
///</remarks>
177
- public AmqpTcpEndpoint ( IProtocol protocol , Uri uri , SslOption ssl ) :
178
- this ( protocol , uri . Host , uri . Port , ssl )
143
+ public AmqpTcpEndpoint ( Uri uri , SslOption ssl ) :
144
+ this ( uri . Host , uri . Port , ssl )
179
145
{
180
146
}
181
147
182
- ///<summary>Construct an AmqpTcpEndpoint with the given
183
- ///IProtocol and Uri.</summary>
184
- ///<remarks>
185
- /// Please see the class overview documentation for
186
- /// information about the Uri format in use.
187
- ///</remarks>
188
- public AmqpTcpEndpoint ( IProtocol protocol , Uri uri ) :
189
- this ( protocol , uri . Host , uri . Port )
190
- {
191
- }
192
-
193
- ///<summary>Construct an AmqpTcpEndpoint with the given
194
- ///Uri, using the IProtocol from
195
- ///Protocols.DefaultProtocol.</summary>
148
+ ///<summary>Construct an AmqpTcpEndpoint with the given Uri.</summary>
196
149
///<remarks>
197
150
/// Please see the class overview documentation for
198
151
/// information about the Uri format in use.
199
152
///</remarks>
200
153
public AmqpTcpEndpoint ( Uri uri ) :
201
- this ( Protocols . DefaultProtocol , uri )
154
+ this ( uri . Host , uri . Port )
202
155
{
203
156
}
204
157
@@ -209,7 +162,7 @@ public AmqpTcpEndpoint(Uri uri) :
209
162
///</remarks>
210
163
public override string ToString ( )
211
164
{
212
- return "amqp-" + Protocol + " ://" + HostName + ":" + Port ;
165
+ return "amqp://" + HostName + ":" + Port ;
213
166
}
214
167
215
168
///<summary>Compares this instance by value (protocol,
@@ -218,7 +171,6 @@ public override bool Equals(object obj)
218
171
{
219
172
AmqpTcpEndpoint other = obj as AmqpTcpEndpoint ;
220
173
if ( other == null ) return false ;
221
- if ( other . Protocol != Protocol ) return false ;
222
174
if ( other . HostName != HostName ) return false ;
223
175
if ( other . Port != Port ) return false ;
224
176
return true ;
@@ -230,7 +182,6 @@ public override bool Equals(object obj)
230
182
public override int GetHashCode ( )
231
183
{
232
184
return
233
- Protocol . GetHashCode ( ) ^
234
185
HostName . GetHashCode ( ) ^
235
186
Port ;
236
187
}
@@ -245,7 +196,7 @@ public override int GetHashCode()
245
196
/// variant specified).
246
197
/// Hostnames provided as IPv6 must appear in square brackets ([]).
247
198
///</remarks>
248
- public static AmqpTcpEndpoint Parse ( IProtocol protocol , string address ) {
199
+ public static AmqpTcpEndpoint Parse ( string address ) {
249
200
Match match = Regex . Match ( address , @"^\s*\[([%:0-9A-Fa-f]+)\](:(.*))?\s*$" ) ;
250
201
if ( match . Success )
251
202
{
@@ -256,18 +207,16 @@ public static AmqpTcpEndpoint Parse(IProtocol protocol, string address) {
256
207
string portStr = groups [ 3 ] . Value ;
257
208
portNum = ( portStr . Length == 0 ) ? - 1 : int . Parse ( portStr ) ;
258
209
}
259
- return new AmqpTcpEndpoint ( protocol ,
260
- match . Groups [ 1 ] . Value ,
210
+ return new AmqpTcpEndpoint ( match . Groups [ 1 ] . Value ,
261
211
portNum ) ;
262
212
}
263
213
int index = address . LastIndexOf ( ':' ) ;
264
214
if ( index == - 1 ) {
265
- return new AmqpTcpEndpoint ( protocol , address , - 1 ) ;
215
+ return new AmqpTcpEndpoint ( address , - 1 ) ;
266
216
} else {
267
217
string portStr = address . Substring ( index + 1 ) . Trim ( ) ;
268
218
int portNum = ( portStr . Length == 0 ) ? - 1 : int . Parse ( portStr ) ;
269
- return new AmqpTcpEndpoint ( protocol ,
270
- address . Substring ( 0 , index ) ,
219
+ return new AmqpTcpEndpoint ( address . Substring ( 0 , index ) ,
271
220
portNum ) ;
272
221
}
273
222
}
@@ -280,13 +229,13 @@ public static AmqpTcpEndpoint Parse(IProtocol protocol, string address) {
280
229
/// optional, and returns a corresponding array of
281
230
/// AmqpTcpEndpoints.
282
231
///</remarks>
283
- public static AmqpTcpEndpoint [ ] ParseMultiple ( IProtocol protocol , string addresses ) {
232
+ public static AmqpTcpEndpoint [ ] ParseMultiple ( string addresses ) {
284
233
string [ ] partsArr = addresses . Split ( new char [ ] { ',' } ) ;
285
234
List < AmqpTcpEndpoint > results = new List < AmqpTcpEndpoint > ( ) ;
286
235
foreach ( string partRaw in partsArr ) {
287
236
string part = partRaw . Trim ( ) ;
288
237
if ( part . Length > 0 ) {
289
- results . Add ( Parse ( protocol , part ) ) ;
238
+ results . Add ( Parse ( part ) ) ;
290
239
}
291
240
}
292
241
return results . ToArray ( ) ;
0 commit comments