1 /* 2 * Collie - An asynchronous event-driven network framework using Dlang development 3 * 4 * Copyright (C) 2015-2017 Shanghai Putao Technology Co., Ltd 5 * 6 * Developer: putao's Dlang team 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 module collie.codec.mqtt.mqttpublishmsg; 12 13 import std.conv; 14 import collie.codec.mqtt.mqttmsg; 15 import collie.codec.mqtt.mqttfixedheader; 16 import collie.codec.mqtt.mqttpublishvariableheader; 17 import collie.codec.mqtt.mqttpublishpayload; 18 19 class MqttPublishMsg : MqttMsg 20 { 21 public: 22 this( 23 MqttFixedHeader mqttFixedHeader, 24 MqttPublishVariableHeader variableHeader, 25 MqttPublishPayload payload) { 26 super(mqttFixedHeader, variableHeader, payload); 27 } 28 29 override 30 MqttPublishVariableHeader variableHeader() { 31 return cast(MqttPublishVariableHeader) super.variableHeader(); 32 } 33 34 35 override 36 public MqttPublishPayload payload() { 37 return cast(MqttPublishPayload) super.payload(); 38 } 39 40 41 ubyte[] content() { 42 MqttPublishPayload pl = cast(MqttPublishPayload) super.payload(); 43 ubyte[] data = pl.publishData(); 44 if (data.length <= 0) { 45 throw new Exception("publish payload is empty!"); 46 } 47 return data; 48 } 49 50 51 // MqttPublishMessage copy() { 52 // return replace(content().dup); 53 // } 54 // 55 // 56 // MqttPublishMessage duplicate() { 57 // return replace(content().dup); 58 // } 59 // 60 // 61 // MqttPublishMessage retainedDuplicate() { 62 // return replace(content().dup); 63 // } 64 // 65 // MqttPublishMessage replace(ubyte[] content) { 66 // return this(fixedHeader(), variableHeader(), content); 67 // } 68 69 // int refCnt() { 70 // return content().refCnt(); 71 // } 72 73 74 // MqttPublishMessage retain() { 75 // content().retain(); 76 // return this; 77 // } 78 79 // @Override 80 // public MqttPublishMessage retain(int increment) { 81 // content().retain(increment); 82 // return this; 83 // } 84 // 85 // @Override 86 // public MqttPublishMessage touch() { 87 // content().touch(); 88 // return this; 89 // } 90 // 91 // @Override 92 // public MqttPublishMessage touch(Object hint) { 93 // content().touch(hint); 94 // return this; 95 // } 96 // 97 // @Override 98 // public boolean release() { 99 // return content().release(); 100 // } 101 // 102 // @Override 103 // public boolean release(int decrement) { 104 // return content().release(decrement); 105 // } 106 } 107