quint16 ClientPrivate::sendPublish(Message &msg) { quint8 header = PUBLISH; header = SETRETAIN(header, msg.retain() ? 1 : 0); header = SETQOS(header, msg.qos()); header = SETDUP(header, msg.dup() ? 1 : 0); Frame frame(header); frame.writeString(msg.topic()); if(msg.qos() > MQTT_QOS0) { if(msg.id() == 0) { msg.setId(gmid++); } frame.writeInt(msg.id()); } if(!msg.payload().isEmpty()) { frame.writeRawData(msg.payload()); } network->sendFrame(frame); return msg.id(); }
quint16 QMQTT::ClientPrivate::sendPublish(const Message& msg) { Message message(msg); quint8 header = PUBLISH; header = SETRETAIN(header, message.retain() ? 1 : 0); header = SETQOS(header, message.qos()); header = SETDUP(header, message.dup() ? 1 : 0); Frame frame(header); frame.writeString(message.topic()); if(message.qos() > QOS0) { if(message.id() == 0) { message.setId(nextmid()); } frame.writeInt(message.id()); } if(!message.payload().isEmpty()) { frame.writeRawData(message.payload()); } _network->sendFrame(frame); return message.id(); }