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.");
            }
        }
示例#2
0
 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)
 {
 }
示例#4
0
 public void DeserializeJson(string json)
 {
     JsonData   = json;
     PacketType = (ControlPacketType)JObject.Parse(json)["type"].Value <int>();
 }
示例#5
0
 protected FixedHeader(ControlPacketType type, ControlPacketFlags flags, UInt32 remainingLength = 0)
 {
     Type            = type;
     Flags           = flags;
     RemainingLength = new EncodedRemainingLength(remainingLength);
 }
示例#6
0
 public ControlPacket(ControlPacketType controlPacketType)
 {
     ControlPacketType = controlPacketType;
 }
示例#7
0
 public void RegisterPacketType <TPacket>(ControlPacketType packetType)
     where TPacket : MQTTPacket, new()
 {
     _packetFactories[(int)packetType] = new DefaultPacketFactory <TPacket>();
 }