|
|
|
@ -3,16 +3,10 @@
|
|
|
|
|
|
|
|
|
|
(require 'map)
|
|
|
|
|
|
|
|
|
|
(defun stomp-connect (host port)
|
|
|
|
|
"Connect to a server supporting the STOMP protocol"
|
|
|
|
|
(message "Not implemented yet"))
|
|
|
|
|
|
|
|
|
|
;; TODO: make this send more than just the command
|
|
|
|
|
(defun stomp-send-frame (process frame)
|
|
|
|
|
"Send a message to a STOMP process"
|
|
|
|
|
(process-send-string
|
|
|
|
|
process
|
|
|
|
|
(format "%s\n\n\u0000\n" (alist-get 'command frame))))
|
|
|
|
|
(process-send-string process (stomp-frame-to-string frame)))
|
|
|
|
|
|
|
|
|
|
(defun stomp-filter-function (callback)
|
|
|
|
|
"Filter function to be used with processes"
|
|
|
|
@ -86,3 +80,18 @@
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(progn (search-forward-regexp "^$") (line-end-position))
|
|
|
|
|
(error nil))))
|
|
|
|
|
|
|
|
|
|
(defun stomp-frame-to-string (frame)
|
|
|
|
|
"Convert a lisp datastructure describing a STOMP frame into a
|
|
|
|
|
string that could be sent to a server or client. The
|
|
|
|
|
datastructure should be an alist and should at least have a
|
|
|
|
|
'command key. Other optional keys are 'headers (another alist)
|
|
|
|
|
and 'content"
|
|
|
|
|
(unless (assq 'command frame)
|
|
|
|
|
(throw 'invalid-frame "A STOMP frame must define a command"))
|
|
|
|
|
(let ((headers (if (assq 'headers frame) (alist-get 'headers frame) '()))
|
|
|
|
|
(content (if (assq 'content frame) (alist-get 'content frame) "")))
|
|
|
|
|
(format "%s\n%s\n%s\u0000"
|
|
|
|
|
(alist-get 'command frame)
|
|
|
|
|
(mapconcat (lambda (h) (format "%s:%s\n" (car h) (cdr h))) headers "")
|
|
|
|
|
content)))
|
|
|
|
|