Exemple #1
0
        /// <summary>
        /// 转换为结构体
        /// </summary>
        /// <returns></returns>
        internal MQTTAsync_connectOptions ToStruct()
        {
            var opt = new MQTTAsync_connectOptions();

            opt.Init();

            opt.keepAliveInterval = this.KeepAliveInterval;
            opt.cleansession      = this.CleanSession ? 1 : 0;
            opt.maxInflight       = this.MaxInflight;
            opt.username          = this.Username.ToUnmanagedPointer();
            opt.password          = this.Password.ToUnmanagedPointer();
            opt.connectTimeout    = this.ConnectTimeout;

            opt.retryInterval      = this.RetryInterval;
            opt.automaticReconnect = this.AutomaticReconnect ? 1 : 0;
            opt.minRetryInterval   = this.MinRetryInterval;
            opt.maxRetryInterval   = this.MaxRetryInterval;

            if (this.Will != null)
            {
                var will = this.Will.ToStruct();
                Marshal.StructureToPtr(will, opt.will, true);
            }
            return(opt);
        }
Exemple #2
0
 public static extern MqttError MQTTAsync_connect(
     IntPtr handle,
     ref MQTTAsync_connectOptions options);