자바 스크립트에서 mqtt 메시징 클라이언트를 처음 사용했습니다. 이 코드가 클라이언트 측 또는 서버 측에서 작성되었다고 말할 수 있습니다.mqtt messaging.client javascript nodejs
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에 서버 코드를 쓸 수 있습니다. 그것을주십시오. 미리 감사드립니다.
Eclipse Paho.js처럼 보입니다. http://www.eclipse.org/paho/ –
mqtt 서버에 서버 측 코드를 제안 해 주실 수 있습니까? 이것은 javscript와 socket.io가있는 nodej입니다 – user2902659
아래에 참조로 사용하는 mqtt nodejs 앱을 작성했습니다. npm을 사용하여이 패키지를 설치하십시오. https://github.com/adamvr/MQTT.js – cherit