|
|
|
@ -26,7 +26,7 @@
|
|
|
|
|
(defun stomp-send-frame (process frame)
|
|
|
|
|
"Send a message to a STOMP process"
|
|
|
|
|
(process-send-string process (stomp-frame-to-string frame)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun stomp-filter-function (callback)
|
|
|
|
|
"Filter function to be used with processes"
|
|
|
|
|
(unless (functionp callback) (signal 'wrong-type-argument 'functionp))
|
|
|
|
@ -69,10 +69,11 @@
|
|
|
|
|
((and headers-end-point)
|
|
|
|
|
(map-put frame 'command (current-word))
|
|
|
|
|
(map-put frame 'headers (stomp-read-headers buffer headers-end-point))
|
|
|
|
|
(map-put frame 'content
|
|
|
|
|
(buffer-substring
|
|
|
|
|
(+ 1 headers-end-point)
|
|
|
|
|
(stomp-find-frame-end-point buffer frame headers-end-point))))
|
|
|
|
|
|
|
|
|
|
(let ((frame-end-point (stomp-find-frame-end-point buffer frame headers-end-point)))
|
|
|
|
|
(if frame-end-point
|
|
|
|
|
(map-put frame 'content (buffer-substring (+ 1 headers-end-point) frame-end-point))
|
|
|
|
|
nil)))
|
|
|
|
|
(t nil)))))
|
|
|
|
|
|
|
|
|
|
(defun stomp-read-headers (buffer end-point &optional headers)
|
|
|
|
@ -96,16 +97,18 @@
|
|
|
|
|
either by using the content-length header or by searching for
|
|
|
|
|
the null octet."
|
|
|
|
|
(with-current-buffer buffer
|
|
|
|
|
(let ((content-length (stomp-frame-header "content-length" frame))
|
|
|
|
|
(headers-end-point(if headers-end-point
|
|
|
|
|
headers-end-point
|
|
|
|
|
(stomp-find-headers-end-point buffer))))
|
|
|
|
|
(if content-length
|
|
|
|
|
(+ headers-end-point 1 (string-to-number content-length))
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(search-forward-regexp "\u0000\\|\u0000\r")
|
|
|
|
|
(- (point) 1))))))
|
|
|
|
|
(let* ((content-length (stomp-frame-header "content-length" frame))
|
|
|
|
|
(headers-end-point
|
|
|
|
|
(if headers-end-point headers-end-point (stomp-find-headers-end-point buffer)))
|
|
|
|
|
(end-point (if content-length
|
|
|
|
|
(+ headers-end-point 1 (string-to-number content-length))
|
|
|
|
|
(progn
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(search-forward-regexp "\u0000\\|\u0000\r" nil t)
|
|
|
|
|
(- (point) 1)))))
|
|
|
|
|
(if (or (> end-point (point-max)) (<= end-point 0))
|
|
|
|
|
nil
|
|
|
|
|
end-point))))
|
|
|
|
|
|
|
|
|
|
(defun stomp-find-headers-end-point (buffer)
|
|
|
|
|
"Find the end of the header part of a STOMP frame."
|
|
|
|
|