internal static ControlPacketFlags GetDefinedFlags(ControlPacketType type) { switch (type) { case ControlPacketType.CONNECT: case ControlPacketType.CONNACK: case ControlPacketType.PUBACK: case ControlPacketType.PUBREC: case ControlPacketType.PUBCOMP: case ControlPacketType.SUBACK: case ControlPacketType.UNSUBACK: case ControlPacketType.PINGREQ: case ControlPacketType.PINGRESP: case ControlPacketType.DISCONNECT: return(new ControlPacketFlags(false, QoSLevel.AtMostOnce, false)); case ControlPacketType.PUBREL: case ControlPacketType.SUBSCRIBE: case ControlPacketType.UNSUBSCRIBE: return(new ControlPacketFlags(false, QoSLevel.AtLeastOnce, false)); case ControlPacketType.PUBLISH: throw new ArgumentException(nameof(type), "There is no defined flag configuration for a PUBLISH control packet."); default: throw new ArgumentException(nameof(type), "Unknown Control Packet Type supplied. Default flags unknown."); } }
public static FixedHeader CreateStandardHeader(ControlPacketType type, UInt32 remainingLength) { if (type == ControlPacketType.PUBLISH) { throw new ArgumentException(nameof(type), "There is no defined flag configuration for a PUBLISH control packet. Use the CreatePublishHeader method to create this header type"); } return(new FixedHeader(type, ControlPacketFlags.GetDefinedFlags(type), remainingLength)); }
public ControlPacketWithPayload(ControlPacketType controlPacketType) : base(controlPacketType) { }
public void DeserializeJson(string json) { JsonData = json; PacketType = (ControlPacketType)JObject.Parse(json)["type"].Value <int>(); }
protected FixedHeader(ControlPacketType type, ControlPacketFlags flags, UInt32 remainingLength = 0) { Type = type; Flags = flags; RemainingLength = new EncodedRemainingLength(remainingLength); }
public ControlPacket(ControlPacketType controlPacketType) { ControlPacketType = controlPacketType; }
public void RegisterPacketType <TPacket>(ControlPacketType packetType) where TPacket : MQTTPacket, new() { _packetFactories[(int)packetType] = new DefaultPacketFactory <TPacket>(); }