This library provides WebSocket server & client implementation for Common Lisp.
WebSocket server implementation is designed to work with Clack, which is a abstraction layer for web servers.
(ql:quickload '(:websocket-driver-server :clack))
(use-package :websocket-driver)
(defvar *echo-server*
(lambda (env)
(let ((ws (make-server env)))
(on :message ws
(lambda (message)
(send ws message)))
(lambda (responder)
(declare (ignore responder))
(start-connection ws)))))
;; Start Wookie server
(clack:clackup *echo-server* :server :wookie :port 5000)
The backend server can be changed by replacing :wookie
by other servers.
(ql:quickload :websocket-driver-client)
(defvar *client* (wsd:make-client "ws:https://localhost:5000/echo"))
(wsd:start-connection *client*)
(wsd:on :message *client*
(lambda (message)
(format t "~&Got: ~A~%" message)))
(wsd:send *client* "Hi")
(wsd:close-connection *client*)