• Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    Clojure
  • License
    Other
  • Created over 11 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Clojure core.async interface to Jetty7's websockets.

Jetty 7 websockets async

Did you know that your familiar friend Jetty 7 (of ring-jetty-adapter fame) can talk websockets? This library provides a Jetty 7 configurator that exposes websockets as core.async channels.

Install | Server quick-start | Client quick-start | Example app | Thanks! | Similar libraries

Install

Add to your project.clj:

[com.keminglabs/jetty7-websockets-async "0.1.0"]

See the in-depth example for fancy core.match message dispatch and a core.async client in ClojureScript.

Server quick start

(require '[com.keminglabs.jetty7-websockets-async.core :refer [configurator]]
         '[clojure.core.async :refer [chan go >! <!]]
         '[ring.adapter.jetty :refer [run-jetty]])

(defn http-handler
  [req]
  {:response 200 :body "HTTP hello" :headers {}})

(def c (chan))

(def ws-configurator
  (configurator c {:path "/"}))

(def server
  (run-jetty http-handler {:configurator ws-configurator
                           :port 8090, :join? false}))

(go (loop []
      (let [ws-req (<! c)]
        (>! (:in ws-req) "Hello new websocket client!")
        (recur))))

Client quick start

(require '[com.keminglabs.jetty7-websockets-async.core :refer [connect!]]
         '[clojure.core.async :refer [chan go >! <!]])

(def c (chan))

(connect! c "ws://remote-server")

(go (loop []
      (let [ws-req (<! c)]
        (>! (:in ws-req) "Hello remote websocket server!")
        (recur))))

Thanks

Zach Allaun for suggesting that the websocket server and client code could be handled symmetrically.

Similar libraries

Take a look at @ptaoussanis's Sente, which provides channels over WebSockets and Ajax on the http-kit server.

More Repositories

1

c2

Declarative data visualization in Clojure(Script).
JavaScript
643
star
2

cljx

Write a portable codebase targeting Clojure/ClojureScript
Clojure
398
star
3

subform-layout

Embeddable layout engine. Like flexbox, but with fewer concepts, applied uniformly.
191
star
4

reflex

Automatic state propogation in ClojureScript
Clojure
184
star
5

zmq-async

Threadsafe Clojure core.async interface to ZeroMQ
Clojure
167
star
6

vagrant-ec2

Use the same chef to provision Vagrant VMs and EC2 instances
Ruby
166
star
7

sandboxtron

Shell
130
star
8

cljs-d3

A ClojureScript faรงade for the D3 JavaScript DOM-manipulation library
Clojure
85
star
9

todoFRP

Functional reactive todo lists
JavaScript
81
star
10

singult

JavaScript Hiccup compiler
CoffeeScript
51
star
11

cljs-react-perf

Performance experiments w/ CLJS React libraries and techniques.
Clojure
40
star
12

json-tagged-literals

More palatable JSON serialization
CoffeeScript
40
star
13

c2-demos

Example C2 visualizations and applications
Clojure
37
star
14

svd2zig

Generate Zig API from SVD register definitions.
Zig
36
star
15

clj-liblinear

A Clojure wrapper for LIBLINEAR, a linear support vector machine library
Clojure
28
star
16

cassowary-coffee

CoffeeScript port of the Cassowary linear constraint solver
CoffeeScript
24
star
17

hicada

A cljs hiccup compiler that helps you be deliberate about runtime interpretation.
Clojure
21
star
18

touchtron

Rust touchpad / usb experiments
Rust
16
star
19

clojurescript-compiler-proposal

Request for comments on ClojureScript compiler interface updates
Clojure
14
star
20

cljs-chosen

ClojureScript interface to Harvest's Chosen <select> library
JavaScript
12
star
21

tidy-codebase-starter-kit

Shell
9
star
22

vomnibus

Assortment of useful geographic data, color schemes, &c.
Clojure
8
star
23

vcf

Genetic variant analysis tool.
JavaScript
8
star
24

YALL1

All your sparse bases are belong to us.
Objective-C
8
star
25

lorax

Provably efficient deep learning
Clojure
5
star
26

prote.cs

Compressed sensing based protein fold search
JavaScript
4
star
27

denizen-demo-compojure

Demo Clojure web app using Denizen for user management
Clojure
4
star
28

question-rust-inlining

A question about inlining and match vs lookup tables in Rust.
LLVM
4
star
29

Rliblinear

R interface to LIBLINEAR, a linear support vector machine library
C++
3
star
30

cljs-hiccup-inference

Minimal example repo of a CLJS Hiccup->React compiler w/ type inference
Clojure
3
star
31

splot

Rust
2
star
32

question-rust-websocket

Rust
2
star
33

profile-cljs

Wherein I examine ClojureScript performance.
Clojure
2
star
34

datomic-fuse-AOT

A hellscape of Clojure+Datomic lazy loading errors.
Clojure
1
star
35

eui

Rust
1
star