-
Notifications
You must be signed in to change notification settings - Fork 0
/
session.lisp
50 lines (40 loc) · 1.28 KB
/
session.lisp
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
(in-package #:butler)
(defvar *DELIM* "<IDS|MSG>")
(defclass message ()
((identities :accessor msg-ids
:initform '()
:type list)
(signature :reader msg-hmac
:writer nil
:initform ""
:type string)
(header :accessor msg-header
:initform '()
:type alist)
(parent-header :accessor parent-header
:initform '()
:type alist)
(metadata :accessor msg-meta
:initform '()
:type alist)
(content :initform '()
:type alist)
(blob :type string)))
(defun make-message (identities header content
&optional
(parent-header '())
(metadata '())
(blob ""))
(make-instance 'message
:identities identities
:header header
:parent-header parent-header
:metadata metadata
:content content
:blob blob))
(defun serialize-message (msg &key (hmac-key nil)))
(defun unserialize-message (byte-string)
(let ((delim-index (search *DELIM* byte-string)))
(values
(subseq byte-string 0 delim-index)
(subseq byte-string (1+ delim-index)))))