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