private void HandleAttachFrame(Attach attach) { if (State != LinkStateEnum.DETACHED && State != LinkStateEnum.ATTACH_SENT) { throw new AmqpException(ErrorCode.IllegalState, $"Received Attach frame but link state is {State.ToString()}."); } if (!IsInitiatingLink && IsSenderLink) { senderSettlementMode = (LinkSenderSettlementModeEnum)attach.SenderSettlementMode; SourceAddress = attach.Source.Address; } if (!IsInitiatingLink && IsReceiverLink) { receiverSettlementMode = (LinkReceiverSettlementModeEnum)attach.ReceiverSettlementMode; TargetAddress = attach.Target.Address; } if (State == LinkStateEnum.DETACHED) { State = LinkStateEnum.ATTACH_RECEIVED; attach.Handle = this.LocalHandle; attach.IsReceiver = this.IsReceiverLink; attach.SenderSettlementMode = (byte)senderSettlementMode; attach.ReceiverSettlementMode = (byte)receiverSettlementMode; attach.InitialDelieveryCount = this.initialDeliveryCount; // send back a cooresponding attach frame Session.SendFrame(attach); } if (State == LinkStateEnum.ATTACH_SENT) { if (IsReceiverLink) { if (attach.InitialDelieveryCount == null) { throw new AmqpException(ErrorCode.InvalidField, "initial-delivery-count must be set on attach from of sender."); } // expecting initial delivery count DeliveryCount = attach.InitialDelieveryCount.Value; } } State = LinkStateEnum.ATTACHED; Session.Connection.Container.OnLinkAttached(this); }
public AmqpLink(AmqpSession session, string name, uint localHandle, bool isReceiverLink, bool isInitiatingLink, uint remoteHandle) { this.Name = name; this.Session = session; this.LocalHandle = remoteHandle; this.IsReceiverLink = isReceiverLink; this.IsSenderLink = !isReceiverLink; this.IsInitiatingLink = isInitiatingLink; this.RemoteHandle = localHandle; this.State = LinkStateEnum.DETACHED; senderSettlementMode = LinkSenderSettlementModeEnum.Mixed; receiverSettlementMode = LinkReceiverSettlementModeEnum.First; DeliveryCount = initialDeliveryCount = 0; }
private void HandleAttachFrame(Attach attach) { if (State != LinkStateEnum.DETACHED && State != LinkStateEnum.ATTACH_SENT) throw new AmqpException(ErrorCode.IllegalState, $"Received Attach frame but link state is {State.ToString()}."); if (!IsInitiatingLink && IsSenderLink) { senderSettlementMode = (LinkSenderSettlementModeEnum)attach.SenderSettlementMode; SourceAddress = attach.Source.Address; } if (!IsInitiatingLink && IsReceiverLink) { receiverSettlementMode = (LinkReceiverSettlementModeEnum)attach.ReceiverSettlementMode; TargetAddress = attach.Target.Address; } if (State == LinkStateEnum.DETACHED) { State = LinkStateEnum.ATTACH_RECEIVED; attach.Handle = this.LocalHandle; attach.IsReceiver = this.IsReceiverLink; attach.SenderSettlementMode = (byte)senderSettlementMode; attach.ReceiverSettlementMode = (byte)receiverSettlementMode; attach.InitialDelieveryCount = this.initialDeliveryCount; // send back a cooresponding attach frame Session.SendFrame(attach); } if (State == LinkStateEnum.ATTACH_SENT) { if (IsReceiverLink) { if (attach.InitialDelieveryCount == null) throw new AmqpException(ErrorCode.InvalidField, "initial-delivery-count must be set on attach from of sender."); // expecting initial delivery count DeliveryCount = attach.InitialDelieveryCount.Value; } } State = LinkStateEnum.ATTACHED; Session.Connection.Container.OnLinkAttached(this); }