mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-19 19:13:11 +08:00
added aspnetcore package and adapted sample app
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>MQTT test</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="node_modules/systemjs/dist/system.js"></script>
|
||||
<script>
|
||||
System.config({
|
||||
packages: {
|
||||
'': {
|
||||
defaultExtension: 'js'
|
||||
}
|
||||
},
|
||||
map: {
|
||||
mqtt: 'node_modules/mqtt/dist/mqtt.min'
|
||||
}
|
||||
});
|
||||
System.import('app/app');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,16 @@
|
||||
import { connect } from "mqtt";
|
||||
|
||||
var client = connect('ws://' + location.host + '/mqtt',
|
||||
{
|
||||
clientId: "client1",
|
||||
});
|
||||
|
||||
client.on('connect', () => {
|
||||
client.subscribe('presence');
|
||||
client.publish('presence', 'Hello mqtt');
|
||||
});
|
||||
|
||||
client.on('message', (topic, message) => {
|
||||
// message is Buffer
|
||||
console.log(message.toString());
|
||||
})
|
||||
Reference in New Issue
Block a user