/// <summary> /// 转换为结构体 /// </summary> /// <returns></returns> internal MQTTAsync_message ToStruct() { if (this.Payload == null) { this.Payload = new byte[0]; } var msg = MQTTAsync_message.Init(); msg.retained = this.Retain ? 1 : 0; msg.payloadlen = this.Payload.Length; msg.qos = (int)this.QoS; msg.payload = Marshal.AllocHGlobal(this.Payload.Length); Marshal.Copy(this.Payload, 0, msg.payload, this.Payload.Length); return(msg); }
public static extern MqttError MQTTAsync_sendMessage( IntPtr handle, [MarshalAs(UnmanagedType.LPStr)] string destinationName, ref MQTTAsync_message msg, ref MQTTAsync_responseOptions response);