Finally, we can remove our handle-message method for :chsk/ws-ping, since we’re
handling it directly from receive-message! now.
This hints that :chsk/ws-ping
was defined earlier in websockets.clj
. As far as I can tell only websockets.cljs
has :chsk/handshake
and :chsk/state
defined on page 150 but nothing for websockets.clj
on page 146 and page 147. Perhaps :chsk/ws-ping
was missed for both clj/cljs and the clj was also missing handshake/state methods.
It does seem that :chsk/ws-ping
implementation is never referenced in the book. We must have overlooked it, sorry about that. It is in the code for the book here: guestbook.routes.websockets if you’re curious.
The :chsk/ws-ping
message can be safely ignored, since it is just a keep-alive ping. Our default handler should do a suitable job of ignoring it.
However, the :chsk/handshake
and :chsk/state
messages are handled by sente itself, and notify our client of any changes to its state. The server will never receive messages of this type, and therefore doesn’t need handlers for them.