Code: Select all
(defpackage :hello
(:use :common-lisp :websocket-driver :clack)
(:export :start :halt))
(in-package :hello)
; (ql:quickload '(:websocket-driver :clack :cl-json))
(defvar *handler*)
(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)))))
(defun start ()
(setq *handler*
(clack:clackup *echo-server* :server :hunchentoot :port 8077)))
(defun halt ()
(clack:stop *handler*))