1 /* 2 * hunt-amqp: AMQP library for D programming language, based on hunt-net. 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 module hunt.amqp.streams.impl.DeliveryImpl; 12 13 import hunt.proton.amqp.messaging.Accepted; 14 import hunt.proton.amqp.transport.DeliveryState; 15 import hunt.proton.message.Message; 16 17 import hunt.amqp.ProtonDelivery; 18 import hunt.amqp.streams.Delivery; 19 import std.concurrency : initOnce; 20 import hunt.net.Connection; 21 import hunt.Exceptions; 22 23 class DeliveryImpl : Delivery { 24 // private static Accepted ACCEPTED = Accepted.getInstance(); 25 26 static Accepted ACCEPTED() { 27 __gshared Accepted inst; 28 return initOnce!inst(Accepted.getInstance()); 29 } 30 31 private Message _message; 32 private ProtonDelivery _delivery; 33 private Connection ctx; 34 35 this(Message message, ProtonDelivery delivery, Connection ctx) { 36 this._message = message; 37 this._delivery = delivery; 38 this.ctx = ctx; 39 } 40 41 42 public Message message() { 43 return _message; 44 } 45 46 public ProtonDelivery delivery() { 47 return _delivery; 48 } 49 50 51 public Delivery accept() { 52 _delivery.disposition(ACCEPTED, true); 53 54 return this; 55 } 56 57 58 public Delivery disposition( DeliveryState state, bool settle) { 59 _delivery.disposition(state, settle); 60 return this; 61 } 62 63 private void ackOnContext() { 64 implementationMissing(false); 65 //if (onContextEventLoop()) { 66 // action.handle(null); 67 //} else { 68 // ctx.runOnContext(action); 69 //} 70 } 71 72 public bool onContextEventLoop() { 73 implementationMissing(false); 74 return true; 75 //return ctx.nettyEventLoop().inEventLoop(); 76 } 77 78 public Connection getCtx() { 79 return ctx; 80 } 81 }