增加编解码异常,增加Mqtt实现,太臃肿了
大石头 authored at 2018-04-23 15:34:06
936.00 B
X
using System;
using System.Diagnostics.Contracts;

namespace NewLife.Net.MQTT.Packets
{
    /// <summary>包类型</summary>
    public class SubscriptionRequest : IEquatable<SubscriptionRequest>
    {
        public SubscriptionRequest(String topicFilter, QualityOfService qualityOfService)
        {
            Contract.Requires(!String.IsNullOrEmpty(topicFilter));

            TopicFilter = topicFilter;
            QualityOfService = qualityOfService;
        }

        public String TopicFilter { get; }

        public QualityOfService QualityOfService { get; }

        public Boolean Equals(SubscriptionRequest other)
        {
            return QualityOfService == other.QualityOfService
                && TopicFilter.Equals(other.TopicFilter, StringComparison.Ordinal);
        }

        public override String ToString() => $"{GetType().Name}[TopicFilter={TopicFilter}, QualityOfService={QualityOfService}]";
    }
}