1 /* 2 * hunt-proton: AMQP Protocol library for D programming language. 3 * 4 * Copyright (C) 2018-2019 HuntLabs 5 * 6 * Website: https://www.huntlabs.net/ 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module hunt.proton.engine.impl.TransportReceiver; 13 14 import hunt.proton.amqp.UnsignedInteger; 15 import hunt.proton.amqp.transport.Flow; 16 import hunt.proton.engine.impl.TransportLink; 17 import hunt.proton.engine.impl.ReceiverImpl; 18 19 class TransportReceiver : TransportLink 20 { 21 private UnsignedInteger _incomingDeliveryId; 22 23 this(ReceiverImpl link) 24 { 25 super(link); 26 link.setTransportLink(this); 27 } 28 29 public ReceiverImpl getReceiver() 30 { 31 return cast(ReceiverImpl)getLink(); 32 } 33 34 override 35 void handleFlow(Flow flow) 36 { 37 super.handleFlow(flow); 38 int remote = getRemoteDeliveryCount().intValue(); 39 int local = getDeliveryCount().intValue(); 40 int delta = remote - local; 41 if(delta > 0) 42 { 43 (cast(ReceiverImpl)getLink()).addCredit(-delta); 44 addCredit(-delta); 45 setDeliveryCount(getRemoteDeliveryCount()); 46 (cast(ReceiverImpl)getLink()).setDrained((cast(ReceiverImpl)getLink()).getDrained() + delta); 47 } 48 } 49 50 UnsignedInteger getIncomingDeliveryId() { 51 return _incomingDeliveryId; 52 } 53 54 void setIncomingDeliveryId(UnsignedInteger _incomingDeliveryId) { 55 this._incomingDeliveryId = _incomingDeliveryId; 56 } 57 58 }