blob: 0ad10c2c45e1679bd6868dc97322611b37f11fd2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
;;;; session.lisp
(in-package :vampire)
;;; SESSION CLASS
(defclass/bknr session (keyed)
((user :std (error "Sessions must be associated with users."))))
;;; SESSION PARAMETER KEYS
(defparameter +session-key+ "vampire-session-key"
"Stored in the browser's local storage")
(defparameter +playlist-connection-key+ "playlist-connection-key"
"Stored in the clog connection object")
;;; SESSION ACCESSORS
(defun session-key (window)
(jonathan:parse (storage-element window :local +session-key+)))
(defun (setf session-key) (val window)
(setf (storage-element window :local +session-key+) (jonathan:to-json val)))
(defun session-user (clog-obj)
(when-let (obj (object-with-key (session-key (window (connection-body clog-obj)))))
(when (typep obj 'session)
(user obj))))
(defun cur-playlist-ctl (obj)
(connection-data-item obj +playlist-connection-key+))
(defun (setf cur-playlist-ctl) (newval obj)
(setf (connection-data-item obj +playlist-connection-key+) newval))
|