Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://gitlab.com/eval/otarta
An MQTT-library for ClojureScript
https://gitlab.com/eval/otarta
clojurescript mqtt
Last synced: 2 months ago
JSON representation
An MQTT-library for ClojureScript
- Host: gitlab.com
- URL: https://gitlab.com/eval/otarta
- Owner: eval
- License: mit
- Created: 2018-09-11T14:57:56.038Z (over 6 years ago)
- Default Branch: master
- Last Synced: 2024-07-25T04:45:38.695Z (6 months ago)
- Topics: clojurescript, mqtt
- Stars: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Otarta
*Canonical repository: https://gitlab.com/eval/otarta*
[![cljdoc badge](https://img.shields.io/badge/cljdoc-latest-blue.svg)](https://cljdoc.org/d/eval/otarta/CURRENT)
[![cljdoc badge](https://img.shields.io/badge/cljdoc-0.3.1-blue.svg)](https://cljdoc.org/d/eval/otarta/0.3.1)
[![discuss at Clojurians-Zulip](https://img.shields.io/badge/clojurians%20zulip-otarta-brightgreen.svg)](https://clojurians.zulipchat.com/#narrow/stream/151157-Otarta)
[![pipeline status](https://gitlab.com/eval/otarta/badges/master/pipeline.svg)](https://gitlab.com/eval/otarta/commits/master)
[![Clojars Project](https://img.shields.io/clojars/v/eval/otarta.svg)](https://clojars.org/eval/otarta)An MQTT-library for ClojureScript.
_NOTE: this is pre-alpha software with an API that will change (see the [CHANGELOG](./CHANGELOG.md) for breaking changes)_
## Installation
Leiningen:
```clojure
[eval/otarta "0.3.1"]
```Deps:
```clojure
eval/otarta {:mvn/version "0.3.1"}
```## Examples
* [CI-Dashboard](https://eval.gitlab.io/ci-dashboard/) (source: https://gitlab.com/eval/ci-dashboard)
## Usage
The following code assumes:
- being in a browser (ie `js/WebSockets` exists. For Node.js [see below](README.md#nodejs).)
- a websocket-enabled MQTT-broker on `localhost:9001` (eg via `docker run --rm -ti -p 9001:9001 toke/mosquitto`)```clojure
(ns example.core
(:require-macros [cljs.core.async.macros :refer [go go-loop]])
(:require [cljs.core.async :as a :refer [> buff (mqtt-fmt/-read mqtt-fmt/string) extract-temperature))
(-write [_fmt v]
(->> v (mqtt-fmt/-write mqtt-fmt/string)))))
```### Node.js
You should provide a W3C compatible websocket when running via Node.js.
I've had good experience with [this websocket-library (>= v1.0.28)](https://www.npmjs.com/package/websocket).With the library included in your project (see https://clojurescript.org/guides/webpack for details), the following will initialize `js/WebSocket`:
```clojure
(ns example.core
(:require [websocket]))(set! js/WebSocket (.-w3cwebsocket websocket))
```## Limitations
- only QoS 0
- only clean-session
- no reconnect built-in
- untested for large payloads (ie more than a couple of KB)## Development
### Develop
``` bash
$ make dev
```### Testing
Via [cljs-test-runner](https://github.com/Olical/cljs-test-runner/):
```bash
# once
$ clojure -Atest# watching
$ clojure -Atest-watch# specific tests
(deftest ^{:focus true} only-this-test ...)
$ clojure -Atest-watch -i :focus# more options:
$ clojure -Atest-watch --help
```## Release
### Install locally
- (ensure no CLJ_CONFIG and MAVEN_OPTS env variables are set - this to target ~/.m2)
- ensure dependencies in pom.xml up to date
- clj -Spom
- make mvn-install version=1.2.3 tag=some-tag
- testdrive locally### Deploy to Clojars
- create (pre-)tag
- push to CI## License
Copyright (c) 2018-2020 Gert Goet, ThinkCreate
Copyright (c) 2018 Alliander N.V.
See [LICENSE](./LICENSE).For licenses of third-party software that this software uses, see [LICENSE-3RD-PARTY](./LICENSE-3RD-PARTY).