Page 1 of 1

WS and static content in hunchentoot

PostPosted: Wed Dec 27, 2017 2:31 pm
by Marutks
Is it possible to serve both static content and websockets?

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*))