Meyvn template for the new Websocket Ring standard

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.

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.

3 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.