25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
-
- namespace MQTTnet.Core.Packets
- {
- public abstract class MqttBasePacket
- {
- public TResponsePacket CreateResponse<TResponsePacket>()
- {
- var responsePacket = Activator.CreateInstance<TResponsePacket>();
- var responsePacketWithIdentifier = responsePacket as IPacketWithIdentifier;
- if (responsePacketWithIdentifier != null)
- {
- var requestPacketWithIdentifier = this as IPacketWithIdentifier;
- if (requestPacketWithIdentifier == null)
- {
- throw new InvalidOperationException("Response packet has PacketIdentifier but request packet does not.");
- }
-
- responsePacketWithIdentifier.PacketIdentifier = requestPacketWithIdentifier.PacketIdentifier;
- }
-
- return responsePacket;
- }
- }
- }
|