WS and static content in hunchentoot

Discussion of Common Lisp

WS and static content in hunchentoot

Postby 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*))
Marutks
 
Posts: 1
Joined: Wed Dec 27, 2017 2:17 pm

Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 11 guests