Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/84codes/mqtt-client.cr
https://github.com/84codes/mqtt-client.cr
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/84codes/mqtt-client.cr
- Owner: 84codes
- License: mit
- Created: 2021-08-09T21:18:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-20T14:06:53.000Z (6 months ago)
- Last Synced: 2024-06-21T18:08:57.866Z (5 months ago)
- Language: Crystal
- Size: 48.8 KB
- Stars: 3
- Watchers: 13
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - mqtt-client.cr - A fast and lightweight MQTT client (Network Protocols)
README
# MQTT-Client
A MQTT client built in Crystal.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
mqtt-client:
github: 84codes/mqtt-client.cr
```2. Run `shards install`
## Usage
```crystal
require "mqtt-client"mqtt = MQTT::Client.new("localhost", 1883)
mqtt.on_message do |msg|
puts "Got a message, on topic #{msg.topic}: #{String.new(msg.body)}"
endmqtt.subscribe("foo", qos: 1)
mqtt.publish("foo", "bar", qos: 1)
mqtt.close
```