<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdnjs.cloudflare.com/ajax/libs/paho-mqtt/1.0.1/mqttws31.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.6.1.min.js" type="text/javascript"></script>
</head>
<body">
<div class="" style="text-align: center;">
<h1>ỨNG DỤNG QUẢN LÝ MÀN HÌNH THÔNG BÁO THÔNG MINH</h1>
</div>
<div class="">
<h2 style="color: purple;">20004241 - Lê Phạm Thanh Tuân</h2>
<h2> Nhập nội dung cần hiển thị tiếng việt không dấu</h2>
<input type="text" id="stMess">
<br>
<br>
<button class="btn" style="background-color: red;color: white;">Gửi thông tin lên màn hình</button>
</div>
</body>
</html>
<script>
$('.btn').click(function(){
message = new Paho.MQTT.Message(document.getElementById('stMess').value);
message.destinationName = "TUAN";
client.send(message);
}
)
client = new Paho.MQTT.Client("broker.emqx.io", Number(8083), "client-" + Math.round(Math.random(100000000, 1000000000)*1000000000));
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
client.connect({onSuccess:onConnect});
function onConnect() {
console.log("onConnect");
client.subscribe("TUAN");
}
function onConnectionLost(responseObject) {
if (responseObject.errorCode !== 0) {
console.log("onConnectionLost:"+responseObject.errorMessage);
}
}
function onMessageArrived(message) {
console.log("onMessageArrived:"+message.payloadString);
}
</script>