internal override int GetWriteLength() { int length = 0; MqttEncoding enc = new MqttEncoding(); length += enc.GetByteCount(ClientIdentifier); if (this.variableHeader.ConnectFlags.WillFlag) { length += enc.GetByteCount(WillTopic); length += enc.GetByteCount(WillMessage); } return length; }
/// <summary> /// Gets the length of the payload in bytes when written to a stream. /// </summary> /// <returns>The length of the payload in bytes.</returns> internal override int GetWriteLength() { int length = 0; var enc = new MqttEncoding(); foreach (var sub in subscriptions) { length += enc.GetByteCount(sub.Key); length += sizeof (MqttQos); } return length; }
/// <summary> /// Gets the length of the write data when WriteTo will be called. /// </summary> /// <returns>The length of data witten by the call to GetWriteLength</returns> public virtual int GetWriteLength() { int headerLength = 0; var enc = new MqttEncoding(); if ((WriteFlags & ReadWriteFlags.ProtocolName) == ReadWriteFlags.ProtocolName) { headerLength += enc.GetByteCount(ProtocolName); } if ((WriteFlags & ReadWriteFlags.ProtocolVersion) == ReadWriteFlags.ProtocolVersion) { headerLength += sizeof (byte); } if ((WriteFlags & ReadWriteFlags.ConnectFlags) == ReadWriteFlags.ConnectFlags) { headerLength += MqttConnectFlags.GetWriteLength(); } if ((WriteFlags & ReadWriteFlags.KeepAlive) == ReadWriteFlags.KeepAlive) { headerLength += sizeof (short); } if ((WriteFlags & ReadWriteFlags.ReturnCode) == ReadWriteFlags.ReturnCode) { headerLength += sizeof (byte); } if ((WriteFlags & ReadWriteFlags.TopicName) == ReadWriteFlags.TopicName) { headerLength += enc.GetByteCount(TopicName.ToString()); } if ((WriteFlags & ReadWriteFlags.MessageIdentifier) == ReadWriteFlags.MessageIdentifier) { headerLength += sizeof (short); } return headerLength; }
/// <summary> /// Gets the length of the payload in bytes when written to a stream. /// </summary> /// <returns>The length of the payload in bytes.</returns> internal override int GetWriteLength() { int length = 0; var enc = new MqttEncoding(); foreach (var topic in subscriptions) { length += enc.GetByteCount(topic); } return length; }