2024年3月24日发(作者:)
ectionLost = onConnectionLost;
t({
userName: user,
password: password,
onSuccess: onConnect,
onFailure: onFailure
});
return false;
});
// the client is notified when it is connected to the server.
var onConnect = function(frame) {
debug("connected to MQTT");
$("#connect").fadeOut({ duration: "fast" });
$("#connected").fadeIn();
ibe(destination);
};
// this allows to display debug logs directly on the web page
var debug = function(str) {
$("#debug").append(TextNode(str + "n"));
};
$("#disconnect").click(function() {
nect();
$("#connected").fadeOut({ duration: "fast" });
$("#connect").fadeIn();
$("#messages").html("");
return false;
});
// 发送数据
$("#send_form").submit(function() {
var text = $("#send_form_input").val();
if (text) {
message = new e(text);
ationName = destination;
(message);
$("#send_form_input").val("");
}
return false;
});
function onFailure(failure) {
debug("failure");
debug(essage);
}
function onMessageArrived(message) {
var p = Element("p");
var t = TextNode(dString);
Child(t);
$("#messages").append(p);
}
function onConnectionLost(responseObject) {
if (ode !== 0) {
debug(Id + ": " + ode + "n");
}
}
}
});
//]]>
