Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bortexz/resocket
JDK11 Clojure WebSocket client with core.async API
https://github.com/bortexz/resocket
clojure core-async jdk11 websocket websocket-client
Last synced: 6 days ago
JSON representation
JDK11 Clojure WebSocket client with core.async API
- Host: GitHub
- URL: https://github.com/bortexz/resocket
- Owner: bortexz
- License: epl-1.0
- Created: 2022-08-29T09:03:48.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-17T11:45:47.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T10:07:10.247Z (7 months ago)
- Topics: clojure, core-async, jdk11, websocket, websocket-client
- Language: Clojure
- Homepage:
- Size: 20.5 KB
- Stars: 27
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# resocket
[![Clojars Project](https://img.shields.io/clojars/v/io.github.bortexz/resocket.svg)](https://clojars.org/io.github.bortexz/resocket)[![Cljdoc](https://cljdoc.org/badge/io.github.bortexz/resocket)](https://cljdoc.org/d/io.github.bortexz/resocket)JDK11 Clojure WebSocket client with core.async API
## Features
- core.async API with `input` and `output` channels for receiving/sending messages, and `closed` promise-chan with details about the closing of the connection.
- Automatically send `ping` frames to the server at given intervals, abort connections that do not `pong` within a certain timeout.
- Close a connection by closing `output` channel, abort within a certain timeout if `on-close` is not received from the server.
- Specify `input` and `output` parsers to take/put your preferred data structure on the channels (maps, vecs, ...) and use the parser for json/edn parsing, etc.
- Minimal dependencies, just `clojure` and `core.async`.
- `reconnector` process to create new connections when the previous ones have been closed, returning a core.async `connections` channel to take new connections from.
- Small codebase, around ~300 LOC docstrings included.## Install
### **Leiningen/Boot**
```clojure
[io.github.bortexz/resocket "0.1.0"]
```### **Clojure CLI/deps.edn**
```clojure
io.github.bortexz/resocket {:mvn/version "0.1.0"}
```## Usage
See the [docs](https://cljdoc.org/d/io.github.bortexz/resocket) for more detailed information about all the options available.
### Quick introduction
Connection:
```Clojure
(require '[bortexz.resocket :as resocket])(let [{:keys [input output closed error]} (a/" {}))]
(when-not error
(a/!! output "Hi from client") ;; Send messages
(a/close! output) ;; Close connection
(a/")})]
(a/go-loop []
(when-let [conn (a/