简体   繁体   English

mqtt messages.client javascript nodejs

[英]mqtt messaging.client javascript nodejs

i'm new to mqtt messaging client in javascript. 我是javascript中的mqtt消息传递客户端的新手。 can any one say that this code is written in client side or server side. 谁能说这个代码是在客户端或服务器端编写的。

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();
};

can anyone write a server code in nodejs,javascript and socket. 任何人都可以在nodejs,javascript和socket中编写服务器代码。 please give it. 请给它。 in advance thanks. 预先感谢。

The handler functions suggest that it is the client side. 处理程序功能建议它是客户端。

PS: If you don't mind, could you tell us which library this is? PS:如果您不介意,您能告诉我们这是哪个图书馆吗? Thanks. 谢谢。

这是使用Eclipse Paho javascript客户端http://eclipse.org/paho ,该客户端在浏览器中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM