ソースアップ
This commit is contained in:
parent
21cd55ccde
commit
5e28005d75
20
Dockerfile
Normal file
20
Dockerfile
Normal file
@ -0,0 +1,20 @@
|
||||
# Use the official Node.js image with Alpine
|
||||
FROM node:alpine
|
||||
|
||||
# Create and change to the app directory
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Copy package.json and package-lock.json files to the working directory
|
||||
COPY package*.json ./
|
||||
|
||||
# Install the dependencies
|
||||
RUN npm install
|
||||
|
||||
# Copy the application source
|
||||
COPY . .
|
||||
|
||||
# Expose the MQTT port
|
||||
EXPOSE 1883
|
||||
|
||||
# Run the MQTT broker
|
||||
CMD ["node", "broker.js"]
|
||||
25
README.md
25
README.md
@ -0,0 +1,25 @@
|
||||
npm install aedes --save
|
||||
npm install aedes-cli --global
|
||||
|
||||
|
||||
```
|
||||
const aedes = require('aedes')();
|
||||
const server = require('net').createServer(aedes.handle);
|
||||
const port = 1883;
|
||||
|
||||
server.listen(port, function () {
|
||||
console.log('Aedes broker started and listening on port ', port);
|
||||
});
|
||||
|
||||
aedes.on('client', function (client) {
|
||||
console.log('Client Connected:', client.id);
|
||||
});
|
||||
|
||||
aedes.on('clientDisconnect', function (client) {
|
||||
console.log('Client Disconnected:', client.id);
|
||||
});
|
||||
|
||||
aedes.on('publish', function (packet, client) {
|
||||
console.log('Published:', packet.payload.toString());
|
||||
});
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user