mqtt的功能请看百度百科,MQTT_百度百科。这里简单说一下,mqtt的功能就是一个发布/订阅的功能例如,接下来,我们做一个例子。现在有A服务器作为发布方,B客户端作为订阅方。如果A发布了消息,那么会向B发送消息,反之亦然,从而进行通信的功能。一、A服务端代码1.建立一个.net5的webapi项目2.nuget引用mqttnet3.MqttService代码usingMQTTnet;usingMQTTnet.Protocol;usingMQTTnet.Server;usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;us