public override bool Equals(object obj) { ProtocolHeader otherHeader = obj as ProtocolHeader; if (otherHeader == null) { return(false); } return(otherHeader.protocolId == this.protocolId && otherHeader.version.Equals(this.version)); }
public override bool Equals(object obj) { ProtocolHeader protocolHeader = obj as ProtocolHeader; if (protocolHeader == null) { return(false); } if (protocolHeader.protocolId != this.protocolId) { return(false); } return(protocolHeader.version.Equals(this.version)); }
public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) : base(transport, connectionSettings) { if (amqpSettings == null) { throw new ArgumentNullException("amqpSettings"); } this.initialHeader = protocolHeader; this.isInitiator = isInitiator; this.amqpSettings = amqpSettings; this.frameDecoder = new FrameDecoder((int)this.Settings.MaxFrameSize); this.sessionsByLocalHandle = new HandleTable<AmqpSession>(this.Settings.ChannelMax.Value); this.sessionsByRemoteHandle = new HandleTable<AmqpSession>(this.Settings.ChannelMax.Value); this.SessionFactory = this; }
public static ProtocolHeader Decode(ByteBuffer buffer) { if (buffer.Length < ProtocolHeader.Size) { throw AmqpEncoding.GetEncodingException("BufferSize"); } uint prefix = AmqpBitConverter.ReadUInt(buffer); if (prefix != ProtocolHeader.AmqpPrefix) { throw AmqpEncoding.GetEncodingException("ProtocolName"); } ProtocolHeader header = new ProtocolHeader(); header.protocolId = (ProtocolId)AmqpBitConverter.ReadUByte(buffer); header.version = new AmqpVersion(AmqpBitConverter.ReadUByte(buffer), AmqpBitConverter.ReadUByte(buffer), AmqpBitConverter.ReadUByte(buffer)); header.Buffer = new ArraySegment<byte>(buffer.Buffer, buffer.Offset - ProtocolHeader.Size, ProtocolHeader.Size); return header; }
public static ProtocolHeader Decode(ByteBuffer buffer) { if (buffer.Length < ProtocolHeader.Size) { throw AmqpEncoding.GetEncodingException("BufferSize"); } uint prefix = AmqpBitConverter.ReadUInt(buffer); if (prefix != ProtocolHeader.AmqpPrefix) { throw AmqpEncoding.GetEncodingException("ProtocolName"); } ProtocolHeader header = new ProtocolHeader(); header.protocolId = (ProtocolId)AmqpBitConverter.ReadUByte(buffer); header.version = new AmqpVersion(AmqpBitConverter.ReadUByte(buffer), AmqpBitConverter.ReadUByte(buffer), AmqpBitConverter.ReadUByte(buffer)); header.Buffer = new ArraySegment <byte>(buffer.Buffer, buffer.Offset - ProtocolHeader.Size, ProtocolHeader.Size); return(header); }
public AmqpConnection(TransportBase transport, ProtocolHeader protocolHeader, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) : this(transport, protocolHeader, true, amqpSettings, connectionSettings) { }
void SendProtocolHeader(ProtocolHeader header) { this.TransitState("S:HDR", StateTransition.SendHeader); this.AsyncIO.Writer.WriteBuffer(header.Buffer, null, null, null); Utils.Trace(TraceLevel.Frame, "SEND {0}", header); }
protected override void OnProtocolHeader(ProtocolHeader header) { Utils.Trace(TraceLevel.Frame, "RECV {0}", header); this.TransitState("R:HDR", StateTransition.ReceiveHeader); Exception exception = null; if (this.isInitiator) { if (!this.initialHeader.Equals(header)) { exception = new AmqpException(AmqpError.NotImplemented, SRClient.ProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString())); } } else { ProtocolHeader supportedHeader = this.amqpSettings.GetSupportedHeader(header); this.SendProtocolHeader(supportedHeader); if (!supportedHeader.Equals(header)) { exception = new AmqpException(AmqpError.NotImplemented, SRClient.ProtocolVersionNotSupported(this.initialHeader.ToString(), header.ToString())); } } if (exception != null) { this.CompleteOpen(false, exception); } }
AmqpConnection IConnectionFactory.CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) { throw new NotImplementedException(); }
static ProtocolHeader() { ProtocolHeader.Amqp100 = new ProtocolHeader(Microsoft.ServiceBus.Messaging.Amqp.ProtocolId.Amqp, new AmqpVersion(1, 0, 0)); ProtocolHeader.AmqpTls100 = new ProtocolHeader(Microsoft.ServiceBus.Messaging.Amqp.ProtocolId.AmqpTls, new AmqpVersion(1, 0, 0)); ProtocolHeader.AmqpSasl100 = new ProtocolHeader(Microsoft.ServiceBus.Messaging.Amqp.ProtocolId.AmqpSasl, new AmqpVersion(1, 0, 0)); }
public AmqpConnection CreateConnection(TransportBase transport, ProtocolHeader protocolHeader, bool isInitiator, AmqpSettings amqpSettings, AmqpConnectionSettings connectionSettings) { if (this.amqpSettings.RequireSecureTransport && !transport.IsSecure) { throw new AmqpException(AmqpError.NotAllowed, SR.AmqpTransportNotSecure); } AmqpConnection connection = new AmqpConnection(transport, protocolHeader, isInitiator, amqpSettings, connectionSettings); Utils.Trace(TraceLevel.Info, "{0}: Created {1}", this, connection); return connection; }
protected abstract void OnProtocolHeader(ProtocolHeader header);
protected override void OnProtocolHeader(ProtocolHeader header) { if (!this.parent.encoding) { this.CompleteOpen(false, null); } else { this.State = AmqpObjectState.HeaderExchanged; } }
void WriteReplyHeader(ProtocolHeader header, bool fail) { Utils.Trace(TraceLevel.Verbose, "{0}: Write reply protocol header {1}", this, header); Utils.Trace(TraceLevel.Frame, "SEND {0}", header); this.args.SetBuffer(header.Buffer); this.args.CompletedCallback = fail ? null : this.writeCompleteCallback; this.bufferWriter.WriteBuffer(this.args); if (fail) { this.args.Exception = new NotSupportedException(header.ToString()); this.parent.OnHandleTransportComplete(this.args); } }