在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:eclipse/paho.mqtt.javascript开源软件地址:https://github.com/eclipse/paho.mqtt.javascript开源编程语言:JavaScript 84.3%开源软件介绍:Eclipse Paho JavaScript clientThe Paho JavaScript Client is an MQTT browser-based client library written in Javascript that uses WebSockets to connect to an MQTT Broker. Project description:The Paho project has been created to provide reliable open-source implementations of open and standard messaging protocols aimed at new, existing, and emerging applications for Machine-to-Machine (M2M) and Internet of Things (IoT). Paho reflects the inherent physical and cost constraints of device connectivity. Its objectives include effective levels of decoupling between devices and applications, designed to keep markets open and encourage the rapid growth of scalable Web and Enterprise middleware and applications. Links
Using the Paho Javascript ClientDownloadingA zip file containing the full and a minified version the Javascript client can be downloaded from the Paho downloads page Alternatively the Javascript client can be downloaded directly from the projects git repository: https://raw.githubusercontent.com/eclipse/paho.mqtt.javascript/master/src/paho-mqtt.js. Please do not link directly to this url from your application. Building from sourceThere are two active branches on the Paho Java git repository, The project contains a maven based build that produces a minified version of the client, runs unit tests and generates it's documentation. To run the build:
The output of the build is copied to the TestsThe client uses the Jasmine test framework. The tests for the client are in:
To run the tests with maven, use the following command:
The parameters passed in should be modified to match the broker instance being tested against. DocumentationReference documentation is online at: http://www.eclipse.org/paho/files/jsdoc/index.html CompatibilityThe client should work in any browser fully supporting WebSockets, http://caniuse.com/websockets lists browser compatibility. Getting StartedThe included code below is a very basic sample that connects to a server using WebSockets and subscribes to the topic This requires the use of a broker that supports WebSockets natively, or the use of a gateway that can forward between WebSockets and TCP. // Create a client instance
var client = new Paho.MQTT.Client(location.hostname, Number(location.port), "clientId");
// set callback handlers
client.onConnectionLost = onConnectionLost;
client.onMessageArrived = onMessageArrived;
// connect the client
client.connect({onSuccess:onConnect});
// called when the client connects
function onConnect() {
// Once a connection has been made, make a subscription and send a message.
console.log("onConnect");
client.subscribe("World");
message = new Paho.MQTT.Message("Hello");
message.destinationName = "World";
client.send(message);
}
// called when the client loses its connection
function onConnectionLost(responseObject) {
if (responseObject.errorCode !== 0) {
console.log("onConnectionLost:"+responseObject.errorMessage);
}
}
// called when a message arrives
function onMessageArrived(message) {
console.log("onMessageArrived:"+message.payloadString);
} Breaking ChangesPreviously the Client's Namepsace was |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论