Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

MqttBasePacket.cs 886 B

12345678910111213141516171819202122232425
  1. using System;
  2. namespace MQTTnet.Core.Packets
  3. {
  4. public abstract class MqttBasePacket
  5. {
  6. public TResponsePacket CreateResponse<TResponsePacket>()
  7. {
  8. var responsePacket = Activator.CreateInstance<TResponsePacket>();
  9. var responsePacketWithIdentifier = responsePacket as IPacketWithIdentifier;
  10. if (responsePacketWithIdentifier != null)
  11. {
  12. var requestPacketWithIdentifier = this as IPacketWithIdentifier;
  13. if (requestPacketWithIdentifier == null)
  14. {
  15. throw new InvalidOperationException("Response packet has PacketIdentifier but request packet does not.");
  16. }
  17. responsePacketWithIdentifier.PacketIdentifier = requestPacketWithIdentifier.PacketIdentifier;
  18. }
  19. return responsePacket;
  20. }
  21. }
  22. }