Skip to content

Commit 0aa8f16

Browse files
merge bug26133 into bug26135
2 parents de36d1f + 411ff94 commit 0aa8f16

File tree

5 files changed

+45
-119
lines changed

5 files changed

+45
-119
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ private Protocols() {}
5454
///<summary>Protocol version 0-9-1 as modified by Pivotal.</summary>
5555
public static IProtocol AMQP_0_9_1
5656
{
57-
get { return new RabbitMQ.Client.Framing.v0_9_1.Protocol(); }
57+
get { return (IProtocol)new RabbitMQ.Client.Framing.v0_9_1.Protocol(); }
5858
}
5959

6060
///<summary>Retrieve the current default protocol variant

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

Lines changed: 0 additions & 106 deletions
This file was deleted.

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
// changes.
5050
using CommonFraming = RabbitMQ.Client.Framing.v0_9_1;
5151
using System.Diagnostics;
52+
using RabbitMQ.Client.Framing.Impl.v0_9_1;
5253

5354
namespace RabbitMQ.Client.Impl
5455
{
@@ -62,12 +63,12 @@ public enum AssemblyState
6263

6364
public class CommandAssembler
6465
{
65-
public AbstractProtocolBase m_protocol;
66+
public ProtocolBase m_protocol;
6667
public AssemblyState m_state;
6768
public Command m_command;
6869
public ulong m_remainingBodyBytes;
6970

70-
public CommandAssembler(AbstractProtocolBase protocol)
71+
public CommandAssembler(ProtocolBase protocol)
7172
{
7273
m_protocol = protocol;
7374
Reset();

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
// the versions we support*. Obviously we may need to revisit this if
5656
// that ever changes.
5757
using CommonFraming = RabbitMQ.Client.Framing.v0_9_1;
58+
using RabbitMQ.Client.Framing.Impl.v0_9_1;
5859

5960
namespace RabbitMQ.Client.Impl
6061
{
@@ -222,11 +223,11 @@ IProtocol IConnection.Protocol
222223

223224
///<summary>Another overload of a Protocol property, useful
224225
///for exposing a tighter type.</summary>
225-
public AbstractProtocolBase Protocol
226+
public ProtocolBase Protocol
226227
{
227228
get
228229
{
229-
return (AbstractProtocolBase)Endpoint.Protocol;
230+
return (ProtocolBase)Endpoint.Protocol;
230231
}
231232
}
232233

@@ -1160,7 +1161,7 @@ public virtual void Open(bool insist)
11601161
string knownHosts = m_model0.ConnectionOpen(m_factory.VirtualHost,
11611162
"", // FIXME: make configurable?
11621163
insist);
1163-
KnownHosts = AmqpTcpEndpoint.ParseMultiple(Protocol, knownHosts);
1164+
KnownHosts = AmqpTcpEndpoint.ParseMultiple((IProtocol)Protocol, knownHosts);
11641165
}
11651166

11661167
public override string ToString()

projects/client/RabbitMQ.Client/src/client/impl/v0_9_1/ProtocolBase.cs

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,18 @@
4141
using RabbitMQ.Client;
4242
using RabbitMQ.Client.Impl;
4343
using RabbitMQ.Util;
44+
using System.Collections.Generic;
4445

4546
namespace RabbitMQ.Client.Framing.Impl.v0_9_1 {
46-
public abstract class ProtocolBase: AbstractProtocolBase {
47+
public abstract class ProtocolBase : IProtocol {
48+
49+
public abstract int MajorVersion { get; }
50+
public abstract int MinorVersion { get; }
51+
public abstract int Revision { get; }
52+
public abstract string ApiName { get; }
53+
public abstract int DefaultPort { get; }
54+
55+
public IDictionary<string, bool> Capabilities = new Dictionary<string, bool>();
4756

4857
public ProtocolBase() {
4958
Capabilities["publisher_confirms"] = true;
@@ -54,25 +63,28 @@ public ProtocolBase() {
5463
Capabilities["authentication_failure_close"] = true;
5564
}
5665

57-
public override IFrameHandler CreateFrameHandler(AmqpTcpEndpoint endpoint,
66+
public abstract MethodBase DecodeMethodFrom(NetworkBinaryReader reader);
67+
public abstract ContentHeaderBase DecodeContentHeaderFrom(NetworkBinaryReader reader);
68+
69+
public IFrameHandler CreateFrameHandler(AmqpTcpEndpoint endpoint,
5870
ConnectionFactory.ObtainSocket socketFactory,
5971
int timeout)
6072
{
6173
return new SocketFrameHandler(endpoint, socketFactory, timeout);
6274
}
6375

64-
public override IModel CreateModel(ISession session) {
76+
public IModel CreateModel(ISession session) {
6577
return new Model(session);
6678
}
6779

68-
public override IConnection CreateConnection(ConnectionFactory factory,
80+
public IConnection CreateConnection(ConnectionFactory factory,
6981
bool insist,
7082
IFrameHandler frameHandler)
7183
{
7284
return new Connection(factory, insist, frameHandler);
7385
}
7486

75-
public override void CreateConnectionClose(ushort reasonCode,
87+
public void CreateConnectionClose(ushort reasonCode,
7688
string reasonText,
7789
out Command request,
7890
out int replyClassId,
@@ -85,7 +97,7 @@ public override void CreateConnectionClose(ushort reasonCode,
8597
replyMethodId = RabbitMQ.Client.Framing.Impl.v0_9_1.ConnectionCloseOk.MethodId;
8698
}
8799

88-
public override void CreateChannelClose(ushort reasonCode,
100+
public void CreateChannelClose(ushort reasonCode,
89101
string reasonText,
90102
out Command request,
91103
out int replyClassId,
@@ -98,9 +110,27 @@ public override void CreateChannelClose(ushort reasonCode,
98110
replyMethodId = RabbitMQ.Client.Framing.Impl.v0_9_1.ChannelCloseOk.MethodId;
99111
}
100112

101-
public override bool CanSendWhileClosed(Command cmd)
113+
public bool CanSendWhileClosed(Command cmd)
102114
{
103115
return cmd.m_method is RabbitMQ.Client.Framing.Impl.v0_9_1.ChannelCloseOk;
104116
}
117+
118+
public AmqpVersion Version {
119+
get {
120+
return new AmqpVersion(MajorVersion, MinorVersion);
121+
}
122+
}
123+
124+
public override string ToString() {
125+
return Version.ToString();
126+
}
127+
128+
public override bool Equals(object obj) {
129+
return (GetType() == obj.GetType());
130+
}
131+
132+
public override int GetHashCode() {
133+
return GetType().GetHashCode();
134+
}
105135
}
106136
}

0 commit comments

Comments
 (0)