summaryrefslogtreecommitdiff
path: root/session.lisp
blob: 770bc8da80261199b52b59d0aecc9b94fa6b3984 (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
;;;; session.lisp

(in-package :vampire)

;;; 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)
  (user-with-key (session-key (window (connection-body clog-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))