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