|
@@ -23,7 +23,7 @@ public class TestMqttDemo : MonoBehaviour
|
|
|
|
|
|
private void OnConnecting()
|
|
|
{
|
|
|
- Debug.Log("MQtt 连接中");
|
|
|
+ Debug.Log("MQtt 锟斤拷锟斤拷锟斤拷");
|
|
|
}
|
|
|
|
|
|
private void onSucceed()
|
|
@@ -34,7 +34,7 @@ public class TestMqttDemo : MonoBehaviour
|
|
|
|
|
|
private void onFaild()
|
|
|
{
|
|
|
- Debug.Log("MQtt 连接失败");
|
|
|
+ Debug.Log("MQtt 锟斤拷锟斤拷失锟斤拷");
|
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
@@ -61,12 +61,12 @@ public class TestMqttDemo : MonoBehaviour
|
|
|
}
|
|
|
|
|
|
|
|
|
- //连接
|
|
|
+ //锟斤拷锟斤拷
|
|
|
public void Connect()
|
|
|
{
|
|
|
DisConnect();
|
|
|
qt = new QTTManager(id, "u@unity1", null, "api-fat1.ghz-tech.com","1883");
|
|
|
- qt.Connect();
|
|
|
+ qt.Connect((Resources.Load("emqxsl-ca") as TextAsset).bytes);
|
|
|
qt.ConnectionFailed += onFaild;
|
|
|
qt.ConnectionSucceeded += onSucceed;
|
|
|
qt.OnConnecting += OnConnecting;
|
|
@@ -76,17 +76,17 @@ public class TestMqttDemo : MonoBehaviour
|
|
|
|
|
|
private void OnClose(EventArgs obj)
|
|
|
{
|
|
|
- Debug.Log("断开连接");
|
|
|
+ Debug.Log("锟较匡拷锟斤拷锟斤拷");
|
|
|
}
|
|
|
|
|
|
- //断开连接
|
|
|
+ //锟较匡拷锟斤拷锟斤拷
|
|
|
public void DisConnect()
|
|
|
{
|
|
|
if (qt != null && qt.IsConnect())
|
|
|
qt.DisConnect();
|
|
|
|
|
|
}
|
|
|
- //订阅
|
|
|
+ //锟斤拷锟斤拷
|
|
|
public void Subscribe()
|
|
|
{
|
|
|
ushort s = qt.Subscribe(
|
|
@@ -104,16 +104,16 @@ public class TestMqttDemo : MonoBehaviour
|
|
|
|
|
|
});
|
|
|
}
|
|
|
- //发送1
|
|
|
+ //锟斤拷锟斤拷1
|
|
|
public void send()
|
|
|
{
|
|
|
qt.Publish("client/" + rid, Encoding.UTF8.GetBytes("111111111111111"), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, false);
|
|
|
- Debug.Log("MQtt 发送" + rid);
|
|
|
+ Debug.Log("MQtt 锟斤拷锟斤拷" + rid);
|
|
|
}
|
|
|
- //发送2
|
|
|
+ //锟斤拷锟斤拷2
|
|
|
public void send2()
|
|
|
{
|
|
|
qt.Publish("client/manage", Encoding.UTF8.GetBytes("111111111111111"), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, false);
|
|
|
- Debug.Log("MQtt 发送manage");
|
|
|
+ Debug.Log("MQtt 锟斤拷锟斤拷manage");
|
|
|
}
|
|
|
}
|