向客户端发送消息

  1. server.PublishAsync(new MqttApplicationMessage()
  2. {
  3. Topic = "mytopic",
  4. QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.ExactlyOnce,
  5. Retain = false,
  6. Payload = Encoding.UTF8.GetBytes("这是服务器消息!")
  7. }); ;