[ANN] Meyvn template for the new Websocket standard in Ring

24 views
Skip to first unread message

Daniel Szmulewicz

unread,
Apr 9, 2024, 11:39:34 AMApr 9
to Clojure
Hello everyone,

Experimental support for WebSockets in Ring was added in 1.11.0-alpha1. I haven't seen examples in the wild yet, so here is mine: a fully fleshed example that shows how to piece everything together.

https://github.com/danielsz/ring-websockets-meyvn

Two points of interest:

  • Browsers don’t expose the Ping and Pong API defined in the WebSocket protocol. Web devs have to roll their own keepalive mechanism in the application layer. This example shows one possibility (sweet and short) of how to do that.
  • With Transit, Clojure data structures, instead of mere bytes or strings, can be exchanged on the socket. This opens the door for routing messages based on keys in maps, etc. Powerful stuff!

Special thanks to James Reeves (ring-websocket-transit) and Ning Sun (rj9a).

I should note that the example is for exploratory use. In production, use Sente.
Reply all
Reply to author
Forward
0 new messages