WS and static content in hunchentoot

Discussion of Common Lisp
Post Reply
Marutks
Posts: 1
Joined: Wed Dec 27, 2017 2:17 pm

WS and static content in hunchentoot

Post by Marutks » Wed Dec 27, 2017 2:31 pm

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

Post Reply