Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dustin/mqtt-hs
Haskell MQTT client.
https://github.com/dustin/mqtt-hs
haskell iot mqtt networking
Last synced: 26 days ago
JSON representation
Haskell MQTT client.
- Host: GitHub
- URL: https://github.com/dustin/mqtt-hs
- Owner: dustin
- License: bsd-3-clause
- Created: 2019-01-04T07:38:41.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-25T07:30:15.000Z (about 1 year ago)
- Last Synced: 2024-05-09T20:27:21.406Z (6 months ago)
- Topics: haskell, iot, mqtt, networking
- Language: Haskell
- Size: 2.62 MB
- Stars: 39
- Watchers: 5
- Forks: 23
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# mqtt
An [MQTT][mqtt] protocol implementation for Haskell.
## Client Examples
### Publish
```haskell
import Network.MQTT.Client
import Network.URI (parseURI)main :: IO ()
main = do
let (Just uri) = parseURI "mqtt://test.mosquitto.org"
mc <- connectURI mqttConfig uri
publish mc "tmp/topic" "hello!" False
```### Subscribe
```haskell
import Network.MQTT.Client
import Network.URI (parseURI)main :: IO ()
main = do
let (Just uri) = parseURI "mqtt://test.mosquitto.org"
mc <- connectURI mqttConfig{_msgCB=SimpleCallback msgReceived} uri
print =<< subscribe mc [("tmp/topic1", subOptions), ("tmp/topic2", subOptions)] []
waitForClient mc -- wait for the the client to disconnectwhere
msgReceived _ t m p = print (t,m,p)
```[mqtt]: http://mqtt.org/