Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Jun 17, 2023
1 parent a04c8db commit 7acc5ac
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ npm install react-native-mqtt-server
## Usage

```js
import { multiply } from 'react-native-mqtt-server';

// ...

const result = await multiply(3, 7);
import { Server, SimpleMQBroker } from 'react-native-mqtt-server';

// Use simple broker
const broker = new SimpleMQBroker();
broker.start();
broker.on('connect', id => console.log('Client connected', id));
broker.on('message', (topic, payload) => console.log('Message received', topic, payload));

// Use as MQTT server directly
const server = new Server();
server.on('connection', client => {
client.on('data', packet => {
console.log('Packet received', packet);
});
});
server.listen(1883);
```

## Contributing
Expand Down

0 comments on commit 7acc5ac

Please sign in to comment.