Make WebSockets from ClojureScript
Now that we’ve created a WebSocket route on the server, we need to write the client-side portion of the socket. Once that’s done we’ll have full-duplex communication between the server and the client.
Create the WebSocket
Let’s start by creating a namespace called guestbook.ws for the WebSocket client. This namespace will be responsible for creating a socket as well as for sending and receiving messages over it. In the namespace declaration, let’s add a reference to cognitect.transit.
|||(:require [cognitect.transit :as t]))|
Next, let’s create an atom to house the channel for the socket and add helpers for reading and writing transit-encoded ...