Set Up WebSockets on the Server
WebSockets require support on both the server and the client side. While the browser API is standard, each server provides its own way of handling WebSocket connections. In this section we’ll take a look at using the API for the Immutant web server that Luminus defaults to.
Let’s start by updating the server-side code in the project to provide a WebSocket connection. Once the server is updated we’ll look at the updates required for the client.
Add WebSocket Routes
The first thing we’ll do is create a new namespace for handling WebSocket connections. Let’s call this namespace guestbook.routes.ws and put the following references in its declaration.
| (ns guestbook.routes.ws ... |
Get Web Development with Clojure, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.