一些测试过可以在国内使用的免费的MQTT服务器的host和ipport
| 地址 | TCP |
|---|
| broker-cn.emqx.io | 1883 |
| mqtt.eclipseprojects.io | 1883 |
| test.mosquitto.org | 1883 |
| test.ranye-iot.net | 1883 |
测试使用的Json
{"你好":"我是发送的消息哦"}
{"Name":"尼桑","Age":223,"Height":176.0,"Width":130.0,"Sex":false,"_scoreDic":{"数学":"123","英语":"23","语文":"3"},"_dateList":["2022-08-13T00:00:00+08:00","2022-08-13T22:15:57.5702248+08:00"],"child":{"ChildName":"GTR","ChlidAge":"12","strList":["chld1","chld2"]}}
class TestJsonItem
{
public string Name="尼桑"
public int Age=223
public float Height=176
public float Width=130
public bool Sex=false
public Dictionary<string, string> _scoreDic=new Dictionary<string, string>()
public List<DateTime> _dateList=new List<DateTime>()
public TestJsonItemChild child=new TestJsonItemChild()
}
public class TestJsonItemChild
{
public string ChildName="GTR"
public string ChlidAge="12"
public List<string> strList=new List<string>()
}
void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e)
{
Debug.Log("Received: " + System.Text.Encoding.UTF8.GetString(e.Message) );
}
client.Publish(top1, System.Text.Encoding.UTF8.GetBytes("Sending from Unity3D!!!"), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, true);