![](/img/trans.png)
[英]In MQTT client “ Uncaught ReferenceError: Messaging is not defined”
[英]mqtt messaging.client javascript nodejs
我是javascript中的mqtt消息傳遞客戶端的新手。 誰能說這個代碼是在客戶端或服務器端編寫的。
client = new Messaging.Client(location.hostname, Number(location.port), "clientId");
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
client.connect({onSuccess:onConnect});
function onConnect() {
// Once a connection has been made, make a subscription and send a message.
console.log("onConnect");
client.subscribe("/World");
message = new Messaging.Message("Hello");
message.destinationName = "/World";
client.send(message);
};
function onConnectionLost(responseObject) {
if (responseObject.errorCode !== 0)
console.log("onConnectionLost:"+responseObject.errorMessage);
};
function onMessageArrived(message) {
console.log("onMessageArrived:"+message.payloadString);
client.disconnect();
};
任何人都可以在nodejs,javascript和socket中編寫服務器代碼。 請給它。 預先感謝。
處理程序功能建議它是客戶端。
PS:如果您不介意,您能告訴我們這是哪個圖書館嗎? 謝謝。
這是使用Eclipse Paho javascript客戶端http://eclipse.org/paho ,該客戶端在瀏覽器中使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.