Skip to content

Commit 565b5c6

Browse files
author
Simon MacMullen
committed
Remove dependency on 0-9-1 classes.
1 parent 510149d commit 565b5c6

File tree

3 files changed

+112
-28
lines changed

3 files changed

+112
-28
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,31 @@ void HandleConnectionStart(byte versionMajor,
720720
byte[] mechanisms,
721721
byte[] locales);
722722

723+
///<summary>Used to send a Connection.StartOk. This is
724+
///special, like Basic.Get.</summary>
725+
[AmqpForceOneWay]
726+
[AmqpMethodMapping(null, "connection", "start-ok")]
727+
void _Private_ConnectionStartOk(IDictionary clientProperties,
728+
string mechanism,
729+
byte[] response,
730+
string locale);
731+
732+
///<summary>Handle incoming Connection.Secure
733+
///methods.</summary>
734+
void HandleConnectionSecure(byte[] challenge);
735+
736+
///<summary>Used to send a Connection.SecureOk. Again, this is
737+
///special, like Basic.Get.</summary>
738+
[AmqpForceOneWay]
739+
[AmqpMethodMapping(null, "connection", "secure-ok")]
740+
void _Private_ConnectionSecureOk(byte[] response);
741+
742+
///<summary>Handle incoming Connection.Tune
743+
///methods.</summary>
744+
void HandleConnectionTune(ushort channelMax,
745+
uint frameMax,
746+
ushort heartbeat);
747+
723748
///<summary>Sends a Connection.TuneOk. Used during connection
724749
///initialisation.</summary>
725750
void ConnectionTuneOk(ushort channelMax,
@@ -778,6 +803,12 @@ public struct ConnectionTuneDetails
778803
///<summary>The peer's suggested heartbeat parameter.</summary>
779804
public ushort m_heartbeat;
780805
}
806+
807+
public class ConnectionSecureOrTune
808+
{
809+
public ConnectionTuneDetails m_tuneDetails;
810+
public byte[] m_challenge;
811+
}
781812
}
782813

783814
namespace RabbitMQ.Client.Apigen.Attributes

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

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@
7171
// the versions we support*. Obviously we may need to revisit this if
7272
// that ever changes.
7373
using CommonFraming = RabbitMQ.Client.Framing.v0_9;
74-
// TODO this actually won't work
75-
using CommonFramingImpl = RabbitMQ.Client.Framing.Impl.v0_9_1;
76-
77-
using ConnectionStartOk = CommonFramingImpl.ConnectionStartOk;
78-
using ConnectionTune = CommonFramingImpl.ConnectionTune;
79-
using ConnectionSecure = CommonFramingImpl.ConnectionSecure;
80-
using ConnectionSecureOk = CommonFramingImpl.ConnectionSecureOk;
8174

8275
namespace RabbitMQ.Client.Impl
8376
{
@@ -1025,31 +1018,22 @@ protected void StartAndTune()
10251018
byte[] challenge = null;
10261019
do {
10271020
byte[] response = mechanism.handleChallenge(challenge, m_factory);
1028-
RabbitMQ.Client.Impl.MethodBase req = null;
1021+
ConnectionSecureOrTune res;
10291022
if (challenge == null) {
1030-
ConnectionStartOk startOk = new ConnectionStartOk();
1031-
startOk.m_clientProperties = m_clientProperties;
1032-
startOk.m_mechanism = mechanismFactory.Name;
1033-
startOk.m_response = response;
1034-
startOk.m_locale = "en_US";
1035-
req = startOk as RabbitMQ.Client.Impl.MethodBase;
1023+
res = m_model0.ConnectionStartOk(m_clientProperties,
1024+
mechanismFactory.Name,
1025+
response,
1026+
"en_US");
10361027
}
10371028
else {
1038-
ConnectionSecureOk secureOk = new ConnectionSecureOk();
1039-
secureOk.m_response = response;
1040-
req = secureOk as RabbitMQ.Client.Impl.MethodBase;
1029+
res = m_model0.ConnectionSecureOk(response);
10411030
}
10421031

1043-
MethodBase resp = m_model0.ModelRpc(req, null, null);
1044-
if (resp is ConnectionTune) {
1045-
ConnectionTune tune = resp as ConnectionTune;
1046-
connectionTune.m_channelMax = tune.m_channelMax;
1047-
connectionTune.m_frameMax = tune.m_frameMax;
1048-
connectionTune.m_heartbeat = tune.m_heartbeat;
1032+
if (res.m_challenge == null) {
1033+
connectionTune = res.m_tuneDetails;
10491034
tuned = true;
10501035
} else {
1051-
ConnectionSecure secure = resp as ConnectionSecure;
1052-
challenge = secure.m_challenge;
1036+
challenge = res.m_challenge;
10531037
}
10541038
} while (!tuned);
10551039
}

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

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,77 @@ public void HandleBasicRecoverOk()
10501050
k.HandleCommand(null);
10511051
}
10521052

1053+
public class ConnectionStartRpcContinuation : SimpleBlockingRpcContinuation
1054+
{
1055+
public ConnectionSecureOrTune m_result;
1056+
public ConnectionStartRpcContinuation() { }
1057+
}
1058+
1059+
public ConnectionSecureOrTune ConnectionStartOk(IDictionary clientProperties,
1060+
string mechanism,
1061+
byte[] response,
1062+
string locale)
1063+
{
1064+
ConnectionStartRpcContinuation k = new ConnectionStartRpcContinuation();
1065+
Enqueue(k);
1066+
try
1067+
{
1068+
_Private_ConnectionStartOk(clientProperties, mechanism,
1069+
response, locale);
1070+
}
1071+
catch (AlreadyClosedException)
1072+
{
1073+
// Ignored, see BasicGet
1074+
}
1075+
k.GetReply();
1076+
return k.m_result;
1077+
}
1078+
1079+
public abstract void _Private_ConnectionStartOk(IDictionary clientProperties,
1080+
string mechanism,
1081+
byte[] response,
1082+
string locale);
1083+
1084+
public void HandleConnectionSecure(byte[] challenge)
1085+
{
1086+
ConnectionStartRpcContinuation k = (ConnectionStartRpcContinuation)m_continuationQueue.Next();
1087+
k.m_result = new ConnectionSecureOrTune();
1088+
k.m_result.m_challenge = challenge;
1089+
k.HandleCommand(null); // release the continuation.
1090+
}
1091+
1092+
public ConnectionSecureOrTune ConnectionSecureOk(byte[] response)
1093+
{
1094+
ConnectionStartRpcContinuation k = new ConnectionStartRpcContinuation();
1095+
Enqueue(k);
1096+
try
1097+
{
1098+
_Private_ConnectionSecureOk(response);
1099+
}
1100+
catch (AlreadyClosedException)
1101+
{
1102+
// Ignored, see BasicGet
1103+
}
1104+
k.GetReply();
1105+
return k.m_result;
1106+
}
1107+
1108+
public abstract void _Private_ConnectionSecureOk(byte[] response);
1109+
1110+
///<summary>Handle incoming Connection.Tune
1111+
///methods.</summary>
1112+
public void HandleConnectionTune(ushort channelMax,
1113+
uint frameMax,
1114+
ushort heartbeat)
1115+
{
1116+
ConnectionStartRpcContinuation k = (ConnectionStartRpcContinuation)m_continuationQueue.Next();
1117+
k.m_result = new ConnectionSecureOrTune();
1118+
k.m_result.m_tuneDetails.m_channelMax = channelMax;
1119+
k.m_result.m_tuneDetails.m_frameMax = frameMax;
1120+
k.m_result.m_tuneDetails.m_heartbeat = heartbeat;
1121+
k.HandleCommand(null); // release the continuation.
1122+
}
1123+
10531124
public abstract void ConnectionTuneOk(ushort channelMax,
10541125
uint frameMax,
10551126
ushort heartbeat);
@@ -1073,9 +1144,7 @@ public string ConnectionOpen(string virtualHost,
10731144
}
10741145
catch (AlreadyClosedException)
10751146
{
1076-
// Ignored, since the continuation will be told about
1077-
// the closure via an OperationInterruptedException because
1078-
// of the shutdown event propagation.
1147+
// Ignored, see BasicGet
10791148
}
10801149
k.GetReply();
10811150
if (k.m_redirect) {

0 commit comments

Comments
 (0)